Rewriting URL paths in ASP.NET 2.0 is referred to as URL Mapping. Instead of putting some code in your Application_BeginRequest method, you can now just put a few lines in your Web.Config file and like magic you can rewrite those URL paths with ease.
With URL Mapping you can turn a not so friendly URL like
Example Web.Config File:
<?xml version="1.0" ?> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.web> <urlMappings enabled="true"> <add url="~/Category.aspx" mappedUrl="~/Default.aspx?category=default" /> <add url="~/Autos.aspx" mappedUrl="~/Default.aspx?category=autos" /> <add url="~/Games.aspx" mappedUrl="~/Default.aspx?category=games" /> <add url="~/Health.aspx" mappedUrl="~/Default.aspx?category=health" /> <add url="~/News.aspx" mappedUrl="~/Default.aspx?category=news" /> </urlMappings> </system.web> </configuration>
Since the Web.Config file is an XML document, you could add functionality to the admin section of your app to add/edit/delete custom URL Mappings. This is definitely something I'm going to keep in mind for future ASP.NET 2.0 app I design/build.
kudos to the ASP.NET team. This is just one of the many new features added to ASP.NET 2.0. And they couldn’t have made it any easier to use!
URL Mapping in ASP.NET 2.0: http://beta.asp.net/QUICKSTART/aspnet/doc/navigation/urlmapping.aspx
If you want to see how to rewrite url paths with ASP.NET 1.x go here: http://edsid.com/blog/articles/160.aspx
- 10 Oct 2020
- 01 Jul 2020
- 06 Apr 2020
- 11 Mar 2020
- 15 Feb 2020
Recent on Build5Nines.com
- 04 Dec 2020
Latest Cloud News: Apple on K8s, IoT, Microsoft Pluton and more! (November 20, 2020 Build5Nines Weekly)20 Nov 2020
Latest Cloud News: .NET 5 Released, Apple Silicon M1 CPU, and more! (November 12, 2020 Build5Nines Weekly)12 Nov 2020
- 11 Nov 2020
Latest Cloud News: Kubernetes, Terraform, Teams Multi-Login and more! (November 5, 2020 Build5Nines Weekly)05 Nov 2020
This site is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com. We also participates in affiliate programs with Udemy, and other sites. This site is compensated for referring traffic and business to these companies.