Hi there!!

I would like to know if is possible to have routing in a website made with classic asp...

In stead of showing this web address :
www.website.com/mypage.asp?id=1

i would love to show this one (like MVC):
www.website.com/mypage/1

Is it possbile?

Thanks to all

Recommended Answers

All 5 Replies

A common approach to url rewriting in classic asp is a work-around. For this to work, you will need to have access to a custom 404 page. In other words, you will depend on IIS to send 404 errors to a custom page in your directory. Most providers have this option for their customers.

Then, when the user arrives to this custom 404 error page, you leverage asp to get the URL via Request.ServerVariables. You then simply parse the contents of that out and use Server.Transfer to provide the correct content back to the user. Dont use Response.Redirect because you want the redirect to happen server-side and not client-side.

Ok... i'm not sure i understand... can you show me an example of code?

Thanks ^_^

I dont have a working example to provide you with..but the general idea is that you want for your web server to take you to a custom asp page when the result of the URL is page not found (404 error). Then on that custom page, you use asp code to get the URL.

it is a bit complicated to explain, but once you understand the concept, it is fairly easy to implement.

I found this article that could help you set this up.

http://she7ata.com/blogs/articles/14/URL+rewritings+on+Classic+ASP+3.0+without+IIS+configurations.html

Although this article shows how to include the target content, the suggestion I gave above is slightly different because I suggested the use of Server.Transfer to perform a redirect on the server and provide the correct content back to the user.

There are a few variations/techniques on how to do this with classic ASP. Once you understand the general approach, you just need to do some testing on your end.

Thanks!! that's perfect

I did what JorgeM suggested on one of my sites to catch 404's and figure out the best page to send the user, but you can also write a script to generate a set of URL rewrite rules for a web.config file. I have done this on same site but it requires running of the script and updating of the webconfig file everytime stuff is added or removed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.