Httphandler for ASP Classic?

407 views Asked by At


Is there any way in ASP Classic to catch HTTP request before it comes to that page? Like in ASP.Net we can catch request at Application_BeginRequest.

Actually what I'm trying to do is to redirect requests to some other pages if asking files from a certain directory. My application is hosted on IIS6. And I suppose IIS6 by default doesn't support for url rewrite. Directory browsing is already disabled.

It would be nice if it could be done just putting a web.config in that certain directory to redirect to other pages.

e.g.

Original Requests: 
Https://stackoverflow.com/NoReadWriteFolder/file1.asp
Https://stackoverflow.com/NoReadWriteFolder/file2.html etc

and I'd like to redirect to 
Https://stackoverflow.com/ReadOnlyFolder/someOtherFile1.asp
Https://stackoverflow.com/ReadOnlyFolder/someOtherFile2.html

I googled but so far no luck, any clue would highly be appreciated.

2

There are 2 answers

2
silver On

For IIS6 I have used Ionic's Isapi Rewrite Filter

https://iirf.codeplex.com/

It supports URL re-writes and re-direction and should do exactly what you need.

On the examples and help pages there are examples for you to re-direct.

0
allski On

background: My application runs for different companies (countries in actual fact) that use the same application.

I use include file called default.asp that runs as standard include for all the scripts I serve. I catch domain requests in URL, detect which company this and then redirect to a URL that I build that includes company code and a "URL prefix" which is added to the URL throughout the session.

To do this, I read URL using request.servervariables, set Session variables, work out my URL prefix and based on this, create revised URL which I then response.redirect.

I hope this may give you an idea for your situation.