Language

How Do I: Work with URLs in ASP.NET Routing?

By Chris Pels|20 minutes|

In this video Chris Pels shows how to specify URLs in a web site that utilizes ASP.NET routing. First, a web site is created and routing is defined in the Global Application Class (.asax). Next, a sample web page is created and a URL based upon a defined route is added to the page using the standard “hard coded” approach, e.g., "~/Stats/Visitors". Another link is then added to the page which dynamically generates the same URL in markup using the RouteValue method which accepts the route name and parameters. The same URL is then implemented using code rather than markup directly in the page. The original route and physical page location are then changed, resulting in the hard coded link no longer working whereas both dynamically generated links function properly. Finally, the value of dynamically generated links is then discussed.

DOWNLOADS: Code (C#)|Code (VB)|MP3|MP4|WMV

This article was originally created on October 15, 2010

Author Information

Chris Pels

Chris Pels – Chris has been instrumental in the architecture, development, and implementation of a wide variety of business systems and databases as a technology consultant since 1986. He has extensive experience in business analysis, technical specifications, database design, several programming languages including C# and VB.NET, and statistical analysis. He holds a Ph.D. from The University of Michigan and has been a speaker at Microsoft TechEd, Microsoft DevDays, VSLive, numerous events in New England