In versions prior to ASP.NET 4.0, you could redirect between two pages, let us say from Default.aspx to About.aspx using Response.Redirect(“About.aspx”).
This caused an extra round trip to the server when users requested for Default.aspx and were then redirected to About.aspx. Moreover this is a temporary redirect (HTTP 302) as shown below using FireBug
ASP.NET 4.0 introduces the RedirectPermanent() helper method which avoids a round trip and is a permanent redirect (HTTP 301) as shown below
Use it as shown below:
Response.RedirectPermanent("About.aspx");If you are new to Temporary and Permanent Redirect, read Redirects: Permanent 301 vs. Temporary 302
Giving me +1 tells me you liked this article! Thanks in advance
Did you like this post?
|
|
|
||
|
|
|
|
Save on Delicious |
|
|
subscribe via rss |
|
subscribe via e-mail |
|
|
print this post |
|
follow me on twitter |




comments
1 Response to "Permanent Redirect in ASP.NET 4.0"Good post, but I cringe at the idea that a 301 does not require an additional trip to the server. The initial request requires the same amount of time as a 302, but it is often cached for future requests. In both cases, the browser requests the page; the server sends the response with the new URL; the browser then requests the new url. This is evident by your firebug screenshots.
The 301 redirect is cached and would probably not be called for future requests.
Post a Comment