Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Response.Redirect in .NET 4.0

Tags:

c#

.net

asp.net

Response.Redirect() no longer working when upgrade the application to ASP.NET 4.0

  • Response.Redirect() is used inside Update panel
  • and we using the AjaxToolKit 4.0

it gives me the error:

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

like image 296
Maged Samaan Avatar asked May 02 '11 15:05

Maged Samaan


People also ask

What is response redirect in C#?

Response.Redirect. Transfers the page control to the other page, in other words it sends the request to the other page. Causes the client to navigate to the page you are redirecting to. In http terms it sends a 302 response to the client, and the client goes where it's told.

What can I use instead of a response redirect?

For instance, instead of a "form" button that causes a postback and redirect, you could use a LinkButton that will behave like a hyperlink, allowing the browser to request the new page directly.

What is difference between response redirect and server transfer?

So, in brief: Response. Redirect simply tells the browser to visit another page. Server. Transfer helps reduce server requests, keeps the URL the same and, with a little bug-bashing, allows you to transfer the query string and form variables.

What is the use of response redirect ()?

redirect() The redirect() method of the Response interface returns a Response resulting in a redirect to the specified URL.


3 Answers

you have to do this

string redirectURL=(a proper url goes here)

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

ScriptManager.RegisterStartupScript(this, typeof(Page), "RedirectTo", script, true);
like image 164
aelias Avatar answered Oct 12 '22 23:10

aelias


UpdatePanel doesn't support resonse.redirect asynchronousely. You should either completely postback the page or avoid using it.

http://forums.asp.net/t/1539851.aspx/1?Response+Redirect+not+working+on+an+UpdatePanel+if+redirecting+to+a+ClickOnce+application+in+some+cases+

http://forums.asp.net/t/1392827.aspx

How to fix error: The message received from the server could not be parsed

like image 27
Priyank Avatar answered Oct 13 '22 00:10

Priyank


Try passing True as the second argument like this:

Response.Redirect("http://...", true);
like image 33
Michael Minton Avatar answered Oct 13 '22 01:10

Michael Minton