URL Routing with ASP.NET 4 Web Forms (VS 2010 and .NET 4.0 Series)
page 5 of 8
by Scott Guthrie
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 32401/ 53

Retrieving URLs within an ASP.NET Web Form

The URL routing engine in ASP.NET can be used to both map incoming URLs to code handlers, as well as be used to programmatically generate outgoing URLs using the same mapping registration logic. 

For example, above when we mapped the /products/{category} URL we gave it a “friendly name” of “products-browse”.  This allows us to now also use the new Page.GetRouteUrl() helper method to lookup the route within the URL routing system, optionally specify parameters to it, and then retrieve an actual URL that it maps back to.  For example, the below code would retrieve a URL value of “/products/software”:

Figure 5


You can access the above helper method within either your code-behind file or within your .aspx markup. 

There is also now a Response.RedirectToRoute() set of methods that you can use to redirect users to a route (regardless of whether it is a MVC or Web Forms handled one) and optionally pass parameters to it.

View Entire Article

User Comments

Title: What about ASP.NET 3.5   
Name: Nicachipal
Date: 2011-02-08 11:08:29 AM
Do we have something similar in ASP.NET 3.5 ?
Title: introduction to asp.net 4.0   
Name: Abdul Sami
Date: 2010-01-06 4:13:44 AM
See if this article can help you people on asp.net 4.0 features


Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-06-18 5:41:13 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search