ASP.NET 4 migrate to routing / mapping
Previously I was using Rewriter.net to rewrite my urls. I used a format like:
<rewrite url="~/(.*)_p(\d+).aspx\??(.*)" to="~/product.aspx?pid=$2&$3"/>
So a page url would look like ~/productname_p21.aspx with an optional querystring.
I'm upgr开发者_StackOverflow社区ading the application to ASP.NET 4 and I would like to use the URL routing in System.Web.Routing, so I can get rid of the 3rd party library Rewriter.net.
I came up with this:
RouteTable.Routes.MapPageRoute("product", "product/{name}/{pid}", "~/product.aspx");
That's all fine, except for the fact that I want to put a 301 permanently moved status on the old-style URL's. How can I accomplish this with the .NET Routing library?
Thanks
A possible way of handling this situation:
Redirect Routes and other Fun With Routing And Lambdas
ASP.NET MVC tips: Routing Engine to aid SEO / 301 Redirect / Tracking
精彩评论