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

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

step6 

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
Comment:
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
Comment:
See if this article can help you people on asp.net 4.0 features

http://www.codeproject.com/KB/aspnet/Whatis_New_ASP_Net_4.aspx

Product Spotlight
Product Spotlight 





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


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