window.navigate and document.location issue - c#

I am working on a system that after completing a record edit and returning control to the calling AJAX script, I refresh the calling page by calling a custom server extension. The odd behavior I am experiencing is after control is returned to the calling script, when the code hits window.navigate or document.location, it attempts to navigate to the url in a new window (which is not the desired behavior). Additionally, the custom server extension is never called - the url appears in the address bar, but then does nothing.
Does anyone have any idea what might be going on? I am running IIS 5.1 on XP sp3 and have tried to get it to work in IE 8 and IE 7, to no avail. Any help would be greatly appreciated.

Okay, my tech lead is apparently a much better Googler than I am.
http://www.faqts.com/knowledge_base/view.phtml/aid/13307/fid/53
Long story short: the page I am calling from is modal and only has an HTML rendering dll loaded. So we changed the return value of the modal page we called from a scalar value to an object with data and now I get to go repopulate the fields manually in the modal calling page.

Related

Mimicking AJAX file uploads in webbrowser control is failing

I am having a problem but I am not sure where.
I have created a website which uses Angular, this might not be pertinent but then again it might be. Of the many features of this site one of them is the ability to upload a file and then get back a response. The response is a simple amount of JSON. The only browser I have to get this working with at this point in time in IE8. avoiding incoming thrown objects - I have tried everything to change this fact, but it is what it is.
I have gotten the site to mimic AJAX uploads by submitting a form and having the response redirected to an iframe. In fact I am using a module that does most of this for me.
So far all this works better than you would believe in IE8. I know right? Unbelievable!
But… there’s always a but…
I need to get this page working when running in a Webbrowser control in a winforms project. I get as far as uploading the file which happens successfully. My REST service gets it, saves it, and returns the correct response. When debugging I can even see that the response is available. But for some reason the load method for the iframe is never called. The iframe which I have made visible on the page is never populated with the JSON.
Again this works when running in IE but not when in the webbrowser control. I get no errors and have breakpoints and debugger statements everywhere. It’s like the response falls in a crack and is ignored.
Would anyone have any suggestions as to why this is happening? crossing fingers
Sorry for the delay I have been ..., well there is no adjective for how busy I have been.
The answer lied in the module that was chosen to help upload files. It worked for IE 8 straight up, but not when running in the web browser control. The module was dynamically binding an onload event to an iFrame which was also being dynamically create to handle the post back. Anyone that has worked with IE and needed to upload files might know of this method. This worked in IE8 but not in the web browser control. We modified it to add the onload event when the iFrame is created and that fixed the issue.

The web page could not be accessed Coded UI Error

I am running a Coded UI test that clicks a hyperlink, for example, "Home" then goes off and does a few different things on the web page, then tries to click the exact same "Home" link and an error is thrown saying
The web page could not be accessed. If the page is refreshing, please
wait until the page refreshes and then perform actions on it.
Now I get this when I am stepping through the test, so I know at the point this link is trying to be clicked the page is not refreshing. Digging through the UITest error logs I see this line every time before the browser refresh error is thrown:
E, 6468, 13, 2013/10/18, 15:08:47.406, 271797587803, QTAgent32_40.exe,
IEDOM : EnsureValid failed for html node: A, 52
I have compared the uitest mappings for this link and the properties are all identical, also the page html is identical.
I am running in IE10, KB2879017. VS2012 4 RC.
Any idea's what's causing this to happen?
NOTE: WaitForControlReady() does nothing to stop this from happening. Also a hard coded Playback.Wait() doesn't help here either.
Failing line of code, this works the first time, but not the second time it is executed in a test.
this.UIWindow.UIDocument.UIHomeHyperlink.WaitForControlReady();
Mouse.Click(this.UIWindow.UIDocument.UIHomeHyperlink);
Remember that the search properties being used for the UIHomeHyperlink mapped control are the exact same the second time these lines are executed. Mouse.Click() execution is when the "Web page not available" error is thrown in VS2012.
After some brainstorming and trial and error testing, came to the conclusion that mapped controls are holding onto properties after being found on a page. For some reason those properties weren't matching up exactly with the page properties on the second time around.
So a "solution" to this problem was to force a new up of the entire mapped UI___Window each time we enter the page. Coded UI prevents this in the designer file by checking if the control is null every time, if it is then the control is new'ed up. If not, then Coded UI uses the same control and it's properties from when it was first defined/discovered. Hope this helps anyone else that was having problems with this error.
There also seems to be a bug in CodedUI when calling .GetParent() twice on the same object tree, which causes this exception to be thrown. We worked around it by determining the parent in another way.
On another workstation (W7) another exception was thrown when calling .GetParent() twice, something about that the IE version should be more than IE10 on 64bit versions of Windows, which was clearly nonsense, since the computer had IE11 installed.

HtmlDocument.InvokeScript Issue in .NET WebBrowser Control

I'm trying to make a wrapper around last.fm and need to invoke some of the javascript functions in the page. Particularly the ones for Stop, Skip, Ban and Love.
InvokeScript seems to work fine with any script function that is within the page HTML itself, but not with scripts loaded from external script files.
For example, the actual call to the skip function is LFM.Flash.Player.skip(), so I tried the following:
_browser.Document.InvokeScript("LFM.Flash.Player.skip");
But all it does is return null and nothing happens on the page.
I've confirmed that that call at least works as typed using the Chrome inspector and the console. (Haven't figured out if there is a way to invoke arbitrary javascript in IE... any suggestions are appreciated)
Is there some special way that that function must be invoked?
Also, yes, I have tried it with and without the parentheses in the script call... still no luck.
Edit: To be clear, I am doing this in the WinForms Browser Control not in an ASP.NET page.
I had the same problem and that solved it for me:
Make sure there's no error in the console by manually loading the page in an external browser
IE Control seems to be caching the pages/scripts ==> I found that refreshing the page in the actual IE browser also refresh the page in .NET IE Control. You can also clear the cache with the debugging tools. I do this for everychange and it works ...
Hope this helps !
Aren't you missing parenthesis when calling skip? Otherwise this only "references" the function, it doesn't call it.

Error not being displayed with updatepanel

It appears like something is stopping my errors from displaying normally an in ASP.NET site.
Scenario 1 - I have an admin screen that has most of its content inside an updatepanel. When the user's session times out. You click a button and nothing happens. It doesn't redirect you to the home page and it doesn't give you an error message.
Scenario 2 - I have some sort of data issue throwing an error - its happening on the staging environment otherwise I'd just debug the code normally. But instead of showing me the error you get the javascript type exclamation mark down the bottom and you need to quickly click on it to bring up a pop up dialog. In IE this happens. In FF there is no error message at all being shown.
My error in this instance is Sys.WebForms.PageRequestManagerServerErrorException: Sequence contains no elements. It then refers to a ScriptResource.axd... so based on this error message I'm having trouble working out what the problem is as I can't reproduce this on my dev environment. I believe its usually related to a linq statement referencing something with no elements but am not sure where the error is occurring or why. But am also wondering why this error appears to be being caught and not displayed look good old fashioned exceptions :)
So not sure if its an updatepanel issue or a scriptmanager related quirk. I imagine I'm using the wrong keywords to google as I can't find anyone else really complaining about the same thing :(
Thanks for any help!
For your first scenario, it seems as though you may need to check via a javascript ajax call whether the user's session is still active, and if not then redirect to the login page.
For the second scenario, I would suggest logging all exceptions on the server using a tool like ELMAH, which will give you a simple UI to view exception details.

ViewState invalid only in Safari

One of the sites I maintain relies heavily on the use of ViewState (it isn't my code). However, on certain pages where the ViewState is extra-bloated, Safari throws a "Validation of viewstate MAC failed" error.
This appears to only happen in Safari. Firefox, IE and Opera all load successfully in the same scenario.
While I second the Channel 9 solution, also be aware that in some hosted environments Safari is not considered an up-level browser. You may need to add it to your application's browscap in order to make use of some ASP.Net features.
That was the root cause of some headaches we had for a client's site that used the ASP Menu control.
My first port of call would be to go through the elements on the page and see which controls:
Will still work when I switch ViewState off
Can be moved out of the page and into an AJAX call to be loaded when required
Failing that, and here's the disclaimer - I've never used this solution on a web-facing site - but in the past where I've wanted to eliminate massive ViewStates in limited-audience applications I have stored the ViewState in the Session.
It has worked for me because the hit to memory isn't significant for the number of users, but if you're running a fairly popular site I wouldn't recommend this approach. However, if the Session solution works for Safari you could always detect the user agent and fudge appropriately.
I've been doing a little research into this and whilst I'm not entirely sure its the cause I believe it is because Safari is not returning the full result set (hence cropping it).
I have been in dicussion with another developer and found the following post on Channel 9 as well which recommends making use of the SQL State service to store the viewstate avoiding the postback issue and also page size.
http://channel9.msdn.com/forums/TechOff/250549-ASPNET-ViewState-flawed-architecture/?CommentID=270477#263702
Does this seem like the best solution?

Categories

Resources