Response.Redirect in .NET 4.0

Response.Redirect() no longer works when upgrading an application to ASP.NET 4.0

  • Response.Redirect() used inside the update panel
  • and we use AjaxToolKit 4.0

he gives me an error:

Error: Sys.WebForms.PageRequestManagerParserErrorException: A message received from the server could not be analyzed. Common causes of this error are a response modified by calls to Response.Write (), response filters, HttpModules, or server trace enabled. Details: parsing error near

+7
source share
8 answers

you need to do it

 string redirectURL=(a proper url goes here) string script = "window.location='" + redirectURL + "';"; ScriptManager.RegisterStartupScript(this, typeof(Page), "RedirectTo", script, true); 
+3
source

Try passing True as the second argument as follows:

 Response.Redirect("http://...", true); 
+2
source

Had the same problem ... You need to replace your version of AjaxControlToolkit with the latest version created specifically for 4.0. This is a replacement for a replacement, so it should influence something else. See Ajaxcontroltoolkit on codeplex

+2
source

We had the same problem. Solved Using PostBackTrigger Management

 <Triggers> <asp:PostBackTrigger ControlID="UploadButton" /> </Triggers> 

http://msdn.microsoft.com/en-us/library/system.web.ui.postbacktrigger.aspx

+2
source

You are trying to redirect to another page with an asynchronous request.

You can overload the Response.Redirect function and set it to false.

 Response.Redirect("URL",false); 

setting it to false will terminate your current request and move on to the next request.

I am 100% sure that it will work for you.

+1
source

You should try to do this as follows:

 Response.Redirect("URL", false); HttpContext.Current.ApplicationInstance.CompleteRequest(); 

You will be redirected and no error will be thrown.

+1
source

I am choking on this problem all day without moving forward. Update the contents of the panel, AsyncPostBackTrigger, if the caller is outside of the updatePanel. If you want to redirect, add it as a PostBackTrigger. Both things in the update panel using:

 <asp:UpdatePanel ID="myUpdatePanel" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:LinkButton ID="link" runat="server" OnClick="link_Click"/> </ContentTemplate> <Triggers> <asp:PostBackTrigger ControlID="link" /> </Triggers> </asp:UpdatePanel> 

My problem is that the controls are generated dynamically inside the custom control due to the list.

Decision:

ScriptManager.GetCurrent (this.Page) .RegisterPostBackControl (myRedirectButton);

In my case, I used listview to bind item data, so I got control using:

 Control myRedirectButton = ListViewDataItem.GetControl("controlId") 

Remember the difference between asynchronous and not one. This was the main point that I did not notice it until a very long time.

+1
source

All Articles