views:

18

answers:

1

Hi,

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&amp;$3"/>

So a page url would look like ~/productname_p21.aspx with an optional querystring.

I'm upgrading 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: 

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

Leniel Macaferi
The first article is perfect, thanks!
peter