0

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

3
Contributors
5
Replies
15
Views
3 Years
Discussion Span
Last Post by vsmash
1

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.

Edited by JorgeM

0

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

Thanks ^_^

0

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.

0

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.