Continually Improving.... let us know how support@devdiamond.net Sign in | Sign up
home articles news blog forum  

 
 


 
Skip Navigation LinksHome > Article > Enhancing URL Rewriting in ASP.Net Architecture
Enhancing URL Rewriting in ASP.Net Architecture
Abstract :
The ASP.Net v1.1 doesn’t come with built-in complex URL Rewriting functionality, so developers have to find a work around, there are number of articles out there about this topic that I came across, the most efficient code I found was Scott’s code, so that code is what this article is playing around with

Views : 1325
Published : Wednesday, November 23, 2005
By
HyperLink

Avarage Rating :
Page Page 1 of 2

I have been looking for a way to enhance my URL Schema, I wanted something more hackable, something easy to remember, as I looked into this I found number of articles, some of those articles required mapping all requests to the ASP.Net Engine, and some required creating Directories with default.aspx files

 

The ASP.Net v1.1 doesn’t come with built-in complex URL Rewriting functionality, so developers have to find a work around, there are number of articles out there about this topic that I came across, the most efficient code I found was Scott Mitchell’s code at the MSDN, so that code is what this article is playing around with

 

I assume you already done some URL Rewriting in your application   

 

Scott is one of the best ASP.Net writers, I have been continuously following his articles, and returning back to it as I need it, he have a good article about URL Rewriting in ASP.Net, which I enhanced for my own use, and came up with new approached for that code, I assume that you read the URL Rewriting in ASP.Net article and played a bit with the code, so please make sure you at least read it once.

 

What’s URL Rewriting?

Is the process of rewriting your http://www.yoursite.com/author.aspx?id=3 to http://www.yoursite.com/yasir, where this URL point to the first one.

 

URL Rewriting is also useful when you change your URL schema, and you have broken links that you want to redirect to the new URLs

 

I guess Scott mentioned this and he have very extensive explanation, but he also mentioned broken links and 404 errors intelligence at the introduction, and as I read his article I didn’t find what I was looking for. He concluded in his solution saying “you have to manually create a directory for each year in which there are blog entries, with a Default.aspx page in the directory. Additionally, in each year directory you need to manually create twelve more directories—01, 02, …, 12—each with a Default.aspx file.”

 

Well, for my approach I can’t do that, I want my URL schema to be http://www.minwar.com/articleid

 

Example

http://www.minwar.com/118 will point to http://www.minwar.com/Learn/ViewArticle.aspx?id=118

 

http://www.minwar.com/116 will point to

http://www.minwar.com/Learn/ViewArticle.aspx?id=116

 

And so on

 

I can’t create folder for each article id and add a Default.aspx page, as Scott said if you can’t do so, then you can workaround to this problem by  having all incoming IIS requests map to the ASP.NET engine, but this have many disadvantages when mapping all requests to the ASP.Net engine even requests for image files will be redirect to the ASP.Net Engine, and you have to have a complex engine on the back to handle this, a good one will be .Text I guess, but this is a lot of work to do at the end, so there have to be an easy workaround

About Author

        Yasir Send Feedback
        Yasir is a .NET expert, with over 5 years experience in Microsoft Technologies, 8 years overall programming experience, he is the owner, founder & primary contributor of Minwar.com, and he also works as IT Director in the hospitality industry.