Response.Redirect() throws an error when called inside Update Panel

When I tried to call Response.Redirect() inside a UpdatePanel, it was throwing me an AJAX error.

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.
Details: Error parsing near ‘
<!DOCTYPE html P’.

I was looking for the solution but I kept getting solution to move that redirect logic outside of the updatepanel.  I wasn’t able to move that logic because of the need of our application.

Finally I found the solution.  Here is what you need to add in web.config under <system.web> section.

<httpModules>

<add name=”ScriptModule” type=”System.Web.Handlers.ScriptModule,System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35″/>

</httpModules>

But technically I would like to know why we need to add this section to resolve the issue.  I am really interested to know if any body knows the reason behind that or find any article explaining why this is needed.

Posted in Microsoft Technology Tagged with: ,
One comment on “Response.Redirect() throws an error when called inside Update Panel
  1. Girish says:

    Its not working even after making modification

Ads