MANISHDAN LANGA
MANISHDAN LANGA

Reputation: 2237

URL rewrite in .net 4.0 with querystring

how can i get Routes URL from

www.xyz.com/department.aspx?p=9&c=8

to

www.xyz.com/department?p=9&c=8

i have try with lots of example but not able to get it done.

RouteTable.Routes.MapPageRoute("department", "/department{*queryvalues}", "~/department.aspx", false, new RouteValueDictionary { { "p", @"\d{4}" } });

Upvotes: 1

Views: 785

Answers (1)

Mark Broadhurst
Mark Broadhurst

Reputation: 2695

Not that this is the answer you wanted. I've found that using routing in Web forms a problematic affair. Its easier to use a Url Rewriter module which intercepts requests and rewrites the url so it gets sent to the correct page.

This is an article from scott gu on how to do it.

http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

If you have any questions on this please ask in the comments or start a chat?

Upvotes: 2

Related Questions