I must be using bad search terms because this has got to be a super-simple question, but I'm not getting any meaningful search hits. I am sending out a link to a page that will expire. MY script checks whether the link is still valid. when valid I have no problems, but when invalid I can't find a simple response and instead I keep stopping myself from writing a hundred lines of code.
I would like to put a simple response.error in the sub Page_Load().
response.error("expired")? something like that? I could do a response.redirect but that would mean a new error handler page. isn't there something super simple? I don't want any other code on the page to execute if the link is invalid.
Dim IsValid as Boolean = YourScriptThatCheckForValidLink()
If Not IsValid Then
Response.Write("This link has expired.")
HttpApplication.CompleteRequest()
End If
not sure what the issue was, but I couldn't find HttpApplication anywhere, IIS always said it didn't recognize it.
ended up with
response.write ("<HTML><head></head><body>This Link has expired</body></HTML>")
response.end()
Related
I am making a GET request to the following url:
http://testsurveys.com/surveys/demo-survey/?collector=10720
and the request works fine. The point is to assign collector ID 10720 to the survey. There is absolutely no issue with this request. However, when I add another parameter the collector ID is passed through as a get parameter but it does nothing. For example:
http://testsurveys.com/surveys/demo-survey/?code=123456&collector=10720
Why does the collector parameter work in the first scenario but not in the second?
That would depend on the code in your backend. There's nothing wrong with the second request. The fact that the parameters do get through to the other end is evidence of this. Try looking at your backend code and see why it isn't being processed properly. Were you coding it with any assumptions in mind that you ended up changing later? If you don't find anything, include the code in your question.
We have a form created by several controllers's new actions, which we reuse via render :new in the create action to display validation error messages. I believe this is the way to go for simple_form and validations. Correct me, if I'm wrong here.
We also have a general language switching mechanic, that redirects to the current_url, with a different locale.
The problem:
After a failed validation and the second rendering of the new form, the language selection throws an error (which would be very misleading to post here). The problem is that the create action expects the validated object, which our language selection does not pass to the current url again.
How would you tackle this problem?
We could try to teach our language switcher about "create" and have it send another post request with the same params, but this seems awful. There would have to be a lot of logic in our little helper and where would we store the objects (at least one kind of them is not persisted at all)?
Someone mentioned (ab-)using a flash message to recreate the object, but it's a huge form with up to 50 validations and this get's uglier with size, I guess.
Storing the object in the session in these cases and have the helper post the object again, if it exists might work. I like this one the most, but it's far from feeling right as well.
We could try to have simple_form use the "new" action instead of just rendering "new", but this seems really bad.
We could disable language switching for create actions altogether, with an alert saying this one step has to be finished in the chosen language.
Do you have any opinions, other suggestions? I'd be very grateful.
Thanks,
Andy
So we changed the language helper to send the same post request again, if it is on a page created by a POST. It ended up looking like this. Not a lot of code added:
def language_link(language)
url_options = { locale: language }
if request.request_method == 'POST'
link_to(language, url_for(params.merge(url_options)), method: :post)
else
link_to(language, url_for(url_options))
end
end
We were carefully making sure we don't end up sending valid data a second time. Creating a second payment, or a second order would be quite bad here for example. We need to keep this in mind in the future as well, when we're creating new post routes accessible on a part of our application where language is changeable. That's the main problem here.
It does not consider PUT requests now because we don't have any edit/update functionality on the part of the app where language is selectable.
We can live with this version in our code. So I post this as an answer. But I'd still be happy to see a better (less dangerous) version, our any thoughts on this at all.
Cheers,
Andy
Now I am testing a online shop website with QTP.
The occured problem is quite tricky.
I already have an account, so I order a product, It will automatically show up my billing address.
What I need to test is that if I were to change this address, this address should be added in "my address"I can set the typed address in a variable. like (newaddress= "Sk ks, ....")
But the problem is I could not identify the created object. Because it was created during the script was running. Has anybody got an idea?
myQTP script to find the "SK ks ... " SPAN.
Set mypage = Browser("Browser").Page("Micasa")
If mypage.webelement("html tag:=span").Exist(3) Then 'or even class:=headline
msgbox "it exists"
Else
msgbox "doesn't exist"
End if
End if
It is hard for me to understand what exactly the problem is, but let me try to help you.
Have you tried putting a breakpoint on the part that gives you trouble? After placing a breakpoint, you can run your script and it automatically breaks on the point of the breakpoint.
From there, you can use the GUI spy and the Object Repository (I assume you use the O.R. and do not use Descriptive Programming?) to detect the object to make the description in the O.R. more generic.
There should be no problem identifying objects that were created during the test run. If QTP doesn't find an object it waits a bit and tries again. Your problem seems to be finding a good description for the WebElement you're looking for.
Looking at the comments on AutomatedChaos's answer it seems that you have a very minimal description (only the html tag). If this is really all you know about your WebElement you can use Visual Relations Identifiers (using QTP11) to find your element.
We have some strange problem here. We have feature event receiver, where we are creating custom fields -> content type -> list. After that, one default item is added. On my VM it was working just fine, but after moving into pre-prod environment, we got this strange behavior with no exception or error in logs.
First thing, item was created only sometimes, with no trace what happened. Mostly it was not created. I even experienced this: when I activated feature, I went to the list and so item there, but after refresh it was gone!
We tried to put there some Thread.Sleep() cycle (while debugging, item was in Items collection, but ItemsCount property of the list was always showing 0).
Now I am out of ideas what is wrong. It's not about execution time (maybe). Looks like, for some reason, SP is killing SPItem.Update before it is created for real and we don't know why. Any help is really welcome!
When you try to access sharepoint items from code and not have admin permissions to update/ delete them then set website website.AllowUnsafeUpdates = true; property
//Set AllowUnsafeUpdates = true to update the database / sharepoint list from code.
FormWeb.AllowUnsafeUpdates = true;
NewItem.Update();
FormWeb.AllowUnsafeUpdates = false;
you code should be like this to make changes in the list.. when you adding item to list.
Use Update statement in same manner when you accessing list and updating its data.
Check whether you updating the list correctly.. There may be some SharePoint security issue.
Reference Link:
http://blogs.msdn.com/b/infopath/archive/2010/04/01/add-items-to-a-sharepoint-list-using-managed-code.aspx.
You can check this [SPSecurity.RunWithElevatedPrivileges][1]
[1]: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges.aspx , link, link
you can check that what is going over there by adding your events in sharepoint..
Check this post and debug it..
http://developmentsolutionsjunction.blogspot.com/2011/06/adding-events-and-eventhandlers-in.html
so I was finally able to find out where the problem was. After deeper study and trying that and this I found out that there was a third party feature. It was adding event to each created list and was deleting everything what wasn't consistent with CT defined by company. This is weird and I don't really understand why somebody wants this. But ok, they pay, their rules.
So if you encounter such problem, try also this possibility.
However, I also leard few things during this, e.g. if you are working with SP instances from web scope, use web scoped features, not site ones, also, SP has a nasty habit to silent som exceptions. Also, if you e.g. take instance of SPWeb from event properties, it doesn't necessarily means it is already created. It takes some time, also, Update() itself is a thing that DB has to perform. Sometimes it's better to alsways check if you really have instance and if not, threadsleep for a while.
Have you used .Update() method in your code??
Could someone provide info about error-handling in wxWidgets or a pointer to documentation?
Specifically, I discovered this behavior: I try to create a wxImage from a file. This is in an event-handler. The file is not present. The call to the image constructor does not throw an exception. (I understand that no wxWidgets code throws exceptions.) A call to image.Ok() returns false. Fine. But after my event-handler exits, wxWidgets gratuitously pops up an error message dialog. That's okay for this particular application, but I wonder how to stop that from happening if I want to handle the error myself. I suspect that the dialog is coming from an event-handler, but I search for things like EVT_ERROR, and came up empty.
There is the class wxLogNull for suppressing those log messages. See http://docs.wxwidgets.org/stable/wx_wxlognull.html#wxlognull where also an example is given.
Read the wxLog overview for more details on how wxWidgets handles this.
You can define your own log target which would throw an exception if an error message is logged. Of course, then you'd probably need to catch it in your event handler anyhow as you probably don't want to just give the user a relatively useless "File couldn't be opened" message but rather a "Image couldn't be opened" one. And if you do this, then why not just test for file.IsOk() directly and use wxLogError() yourself? IOW you can do what you want but I don't really see how is it better than the traditional exception-less way of doing things in this particular case.