TheEdge
TheEdge

Reputation: 9871

Webforms Response.Redirect() different behaviour for route and page

I have the following route configuration in place:

aRoutes.MapPageRoute("routePageA", "page/a", "~/Pages/A.aspx");
aRoutes.MapPageRoute("routePageB", "page/b", "~/Pages/B.aspx");

I have code in a click handler for A.aspx that is redirecting to B.aspx however I get different behaviour as follows:

  1. When redirecting to the route without ending request:

    Response.Redirect("/page/b");

the events fired are:

the events fired are:

the events fired are:

The behaviour I am expecting is 3. But why does this only behave this way when the ASPX is the redirection target. Can someone explain to me why directing to a route produces different behavior?

Upvotes: 0

Views: 804

Answers (1)

Aman Sahni
Aman Sahni

Reputation: 212

You can use RedirectToRoute instead of Response.Redirect(). Try this instead.

return RedirectToRoute("routePageB");

Upvotes: 0

Related Questions