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

by Chris Pels

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.

▶ Watch video (20 minutes)