I need to solve a problem with url rewrite using routing feature in asp.net 4.0. when user type url like
www.mysite.com/product.aspx?id=101
then right page shows but suppose if i change the page location and name and when user type url like
www.mysite.com/product.aspx?id=101
then page not found error will occur.
So please tell me how could I solve this situation using asp.net 4.0 routing feature. is it possible ?
I handler routing like and my sample code
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RouteTable.Routes.MapPageRoute
("Source", "Source/{ID}/{Title}", "~/Source.aspx");
RouteTable.Routes.MapPageRoute
("Source1", "MyData/Source/{ID}/{Title}", "~/MyData/Source.aspx");
}
The code above is just sample and I this way do the url rewrite. It is very easy.
But if I need to solve my above url mapping problem with routing then how could I do so and what kind of code I need to write in Application_Start event.
I want when user type
www.mysite.com/product.aspx?id=101
then it should redirect to
www.mysite.com/prod/Myproduct.aspx?prodid=101
This url. So please guide me how could I do this kind of mapping with the help of asp.net 4.0 routing feature.