Saturday 2 February 2008

Using Response.Redirect in ASP.NET Ajax Update Panel

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 PUB'.

 

Solution to the above exception is given below:

 

 Solution 1


private void RedirectTo(string url)

    {

      //url is in pattern "~myblog/mypage.aspx"

      string redirectURL = Page.ResolveClientUrl(url)

      string script = "window.location = '" + redirectURL + "';";

ScriptManager.RegisterStartupScript(this, typeof(Page), "RedirectTo", script, true);

    } 

 


 

 

Solution 2 (Recommended)

In web.config,  Add the key


 <httpModules>

     <add name="ScriptModule" type="System.Web.Handlers.ScriptModule,

     System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,

     PublicKeyToken=31bf3856ad364e35"/>

</httpModules>

 


This will work like magic, you dont need to change anything in you code, you can use your existing Response.Redirect

To get more indepth knowledge of ScripModule, click on the link below

Share:

0 comments:

Post a Comment