How to do URL Rewriting With ASP.NET 4.0 and C# - ASP.NET 4.0

Posted by Abhi24h under C# on 10/17/2012 | Points: 10 | Views : 11383 | Status : [Member] | Replies : 2
Help me..
How to do URL Rewriting or Mapping With ASP.NET 4.0 and C# - ASP.NET 4.0 ?

Abhishek Kumar
http://abhishekkumar.in
Redeemer Engisoft Pvt.Ltd



Responses

Posted by: Vasanthmvp on: 10/17/2012 [Member] Starter | Points: 25

Up
0
Down
Hi, we call it as URL-Routing in asp.net.
To be in brief..
1. first we have to register our routes in Global.asax file. Before, starting of our application this file is executed and all the routes get registered.
2. Then in the RegisterRoutes Method (Using System.Web.Routing namespace), routes.MapPageRoute accepts 3 parameter (RouteName, VirtualPath, Physical Path) which helps us to map the "VIRTUAL PATH" with "PHYSICAL PATH."
3. We can also create a route collection under one route name.
4. Only a virtual path is visible to the user as if a Folder is there and sub folder, where as they are not in actual.
5. It makes user friendly as well as SEO friendly
6. To get the values from URl-Re-written query string. RouteData.Values[""] is used instead of Request.QueryString().

To see an exmaple, refer the article.. here is a clear explanation with example.
http://www.dotnetfunda.com/articles/article1450-aspnet-40-routing.aspx
To know more on theory part,
refer this: http://www.dotnetfunda.com/articles/article870-a-walkthrough-to-aspnet-40-url-routing.aspx
In case any doubt, let me know.
Regards,

Awesome Coding !! :)

Abhi24h, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 10/17/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
Follow this url to download sample project
www.codedigest.com/Articles/ArticleFiles/ZIPS/294.zip

Abhi24h, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response