views:

152

answers:

2

I have been using DotNetOpenAuth's "OpenIdTextBox" control on our login page. We used VS 2008 + .NET 3.5 + Ajax UpdatePanel without any issues.

Today we tried to upgrade the whole project to VS 2010 + .NET 4.0, the Ajax UpdatePanel gives me a javascript error when it redirects to the provider (such as Google) to sign in.

"Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled"

Is there any settings I can make this work? The weird thing is... it worked on VS 2008 + .NET 3.5. Thanks....

+1  A: 

I don't know how the UpdatePanel works, but the OpenIdTextBox control needs the ability to redirect the entire browser document to another URL, which perhaps UpdatePanel isn't allowing because it only expects a content response to update a small area of the web page. So perhaps OpenIdTextBox is fundamentally incompatible with UpdatePanel -- just a guess.

I wonder if you can elect somehow at the server side while processing the page to disable the UpdatePanel's optimizations, if for example the OpenIdTextBox_LoggingIn event was fired.

Otherwise of course you can move the text box outside the UpdatePanel, but perhaps that can't be done while maintaining the appearance of yoru web page.

I could tell you how to override the way OpenIdTextBox redirects the web page, but anything you might do that is equivalent would likely run into the same problem.

Andrew Arnott
Hi Andrew.. Yes, if you can tell me how to overrite OpenIdTextBox redirect please? that would be helpful.. really appreciated that.
userb00
Override the LoggingIn event, and set the `e.Cancel = true` to stop the control from doing the redirect. Then you can use the information in `e.RedirectingResponse` to perform the redirect yourself. Be careful though. It's *not* always just a simple 301 Redirect with a URL. That `RedirectingResponse` can include a self-posting HTML FORM for extra large auth requests. So you have to send *all* the data in that object to the client to be reliable.
Andrew Arnott
Thanks Andrew!!!
userb00
You're welcome. (slight correction: `e.RedirectionResponse` above should be `e.Request.RedirectingResponse`)
Andrew Arnott
A: 

Thanks Andrew! It worked (I am answering to my own post). Basically, I solved this Ajax problem by using "Response.RedirectLocation".

According to some articles, this is an Ajax friendly call for some reasons, I don't exactly know what's the difference because I guess "e.Request.RedirectingResponse" is doing the same thing. Anyways, I then extacted the location from "RedirecingResponse" header. I tested with 8 providers, it seems working!

e.Cancel = true; 
OutgoingWebResponse webResponse = e.Request.RedirectingResponse; 
string location = webResponse.Headers["Location"]; 
Response.RedirectLocation = location; 
userb00