| « ASP Url Rewriting - Part Two "The Practice" | Gamers TV Show » |
Gotta post the ads, Sorry:
In this post, i will be talking about the tools to use for Rewriting (or Filtering) URLs in ASP. The key to note is that i am using 3.5 Framework but the Rewriting library is utilizing 1.1 Framework for the codebase. I have yet to get the original Rewriting library translated to 2.0 but from what i have seen, there isnt a whole lot of change as far as the library is concerned. I will take the code-base and translate it later on, when i get the chance so that way it is kept up to date with current language framework.
Note: I will be utilizing Microsofts MSDN site tags as a reference for this RegEx rewrite and showing you the RegEx check validation for various Query Strings. Intellectual Knowledge and Property
Notice: I DO NOT know their (Microsoft) query string format, i will not be able to translate this as such. DO NOT ASK ME FOR IT, as this is proprietary to Microsoft and their internal logic. I will NOT try to understand anything they publish and will not attest to understanding anything they publish. This Posting is nothing more than an attempt to help you understand the coding necessary to pull this style off and nothing more.
CONTENT AT HAND:
In the past, I have dealt with UNIX .htaccess files to do URL masking and/or url rewriting. If you have gone to Wikipedia and browsed through their plethora of information, you may have run across such things as http://en.wikipedia.org/wiki/Donald_Trump,_Jr. where the URL in the address bar seems to be the URL being passed. But what the user doesn't see is that in fact this address is translated to be something similar to http://wikipedia.org/index.php?lang=en&topic=Donald_Trump,_Jr.&mode=view (this is not exactly what is going on but you should get the idea).
This technique is used to allow someone to link to this topic without having to type the rather long address, that would result, excluding the "Select", "Copy/Cut", and "Paste" method.
Recently, I ran into a need to do something similar to what Wikipediahas done and shorten the address bar url, to keep the address looking more clean, in ASP.Net. In doing so, i spent about a week, or so, researching various links from Google and there was not one single resource outside of MSDN that was very knowledgeable to the content i was searching for. Seems this is a proprietary piece of information for various locations that use it. To this end, I am willing to advertise my knowledge in the hope that others will become more educated and knowledgeable in regards to ASP.Net URL Rewriting/Parsing. I will be using Microsoft's MSDN site address(es) as a basis for comparison and understanding of what is returned.
What is needed:
- VS2k5+ (i am using 2k8)
- Understanding of Web.Config and how it relates to the website - Read over this topic URL Rewriting in ASP.NET
- Download the URL Rewriting source code HERE!
- Web-application project to test against.
- Understanding of how to utilize and obtain QueryString information
- Understanding Regular Expressions (RegEx)
- (Optional) This is an excellent tool to use when you have a pattern you want to run against your RegEx to see if it validates against your pattern. Have either have the Web interface RegExr Web up and running or install the desktop version RegExr Desktop
the good stuff! First off take a non-descript page, for example: http://domain.com/data.aspx?mode=Edit&type=Production, and you want to simplify this url to be more representative but less descriptive as to what information is being passed through the query string.
Style available to use:
- http://domain.com/data/production/edit.aspx
- http://domain.com/data/production(edit).aspx
- http://domain.com/data/edit/production
- http://domain.com/data(production, edit).aspx
And the list can go on and on.
Feedback awaiting moderation
This post has 65 feedbacks awaiting moderation...
Recent comments