HTML | CSS | JavaScript | ASP.NET | PHP | C# | Java | VB.NET | MS SQL | MySQL | Flash
UrlMappings — An ASP.NET feature I forgot about
So, the other day I came across a situation where I needed to provide a link to a user to a specific page within my web application; but that link also required that I provided specific values for a couple query string parameters which would take them right to the data they was looking for. I wanted to avoid the messy looking querystring at the end of the URL so I wondered if there was some way around it. I started thinking and the first thing came to mind was a URL mapping feature. After some poking around on Bing, I was taken to a MSDN page that reminded me that ASP.NET starting with version 2.0 came will a simple url mapper that would be perfect for what I was trying to accomplish.
To get the feature to work, all you have to do was add configuration element to your web.config and then you are off and running. Here is what it looked like:
<urlMappings> <add url="~/SomePageThatDidNotHaveToExist.aspx" mappedUrl="~/SomePageThatHasToExist.aspx?id=123&cat=somecat" /> </urlMappings>
Once you place this section in the <system.web> section, all your users would have to access is the SomePageThatDidNotHaveToExist.aspx page and ASP.NET would translate that url into the actual url with the additional querystring parameters at the very end. So, I didn’t have to use any third party components since my needs were very simple. Hope you find some use for this forgotten feature. Until next time…
Happy Programming!
| Print article | This entry was posted by admin on August 27, 2009 at 3:26 pm, and is filed under ASP.NET. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |