tailieunhanh - ASP.NET 4 Unleased - p 116

1124 CHAPTER 24 Advanced Navigation Remapping URLs The simplest way to remap a URL is to specify the remapping in your application’s web configuration file. For example, the web configuration file in Listing remaps the page to the page. LISTING The configuration file in Listing contains a element. This element can contain one or more elements that remap a page from a URL to a mapped Url. The mappedUrl attribute can contain query strings. However, it cannot contain wildcards. You can use the element only when performing simple page-to-page mappings. After. | 1124 CHAPTER 24 Advanced Navigation Remapping URLs The simplest way to remap a URL is to specify the remapping in your application s web configuration file. For example the web configuration file in Listing remaps the page to the page. LISTING xml version configuration urlMappings add url mappedUrl urlMappings configuration The configuration file in Listing contains a urlMappings element. This element can contain one or more elements that remap a page from a URL to a mapped Url. The mappedUrl attribute can contain query strings. However it cannot contain wildcards. You can use the urlMappings element only when performing simple page-to-page mappings. After you add the web configuration file in Listing to your application any requests for the page are modified automatically to requests for the page. It doesn t matter whether the page actually exists. If the page does exist you can never open the page. NOTE The tilde character has a special meaning when used with a path. It represents the current application root. A forward slash at the start of a URL on the other hand represents the website root. You can use the tilde only with properties of ASPNET controls. For example you can use it with the ASPNET Image control s ImageUrl property but you cannot use it with the HTML img src attribute. In code you can use the tilde character with a path by using the method. This method automatically expands the tilde to the application root. When working with remapped URLs you often need to determine the original URL that a user requested. For example you might want to display a message that tells users to update their bookmarks favorites to point to the new URL. From the Library of Wow eBook Remapping URLs 1125 You can use the following to determine the current URL Returns the original URL before being .