views:

676

answers:

3

I need to redirect some of the older pages in my application to new pages. I thought urlMapping in web.config is the efficient way to achieve this. But there is also another way to redirect using global.asax. Which one is the efficient way for this. At what point in request execution does this asax and config file comes into the picture?

A: 

Use the URL Rewrite ISAPI filter to do the redirect - it is lower level and will run first, so you don't take a hit on the asp.net engine.

The page I linked also mentions ASP.NET Routing, the differences between them and how to choose between the two.

Oded
A: 

Here is one of way to write redirect by HttpHandler.

http://www.developerfusion.com/article/4643/implementing-http-handlers-in-aspnet/

Saar
+1  A: 

If I were mapping existing pages to new ones I would keep the old pages in place and flush a 301 permanent redirect to the client. This will preserve SEO, assuming this is a public site.

 Response.StatusCode = 301;
 Response.Status = "301 Moved Permanently";
 Response.RedirectLocation = location; // static, configuration, or database
 Response.End();

Overall I would go with rerouting instead of rewriting. Two great links for this are:

For an overview of some different approaches prior to rerouting check out Scott Gu's Tip/Trick: Url Rewriting with ASP.NET

blu