Can asp.net HttpModule forward requests to the asp.dll? - iis

What I'm trying to achieve:
Intercept requests for .asp files using an asp.net application
then re-write the url to something search engine friendly
then pass the request onto the asp.dll to handle the request.
How Im trying to acheive it:
I'm trying to get intelligencia url re-writing working for a classic asp application by
changing the IIS mapping for the website so that .asp extensions are handled by an asp.net application.
The intelligencia asp.net url re-writer then rewrites the url.
The requested .asp page is then forwarded to the asp.dll for processing. Can this bit be done? Any ideas?
My limitations:
Shared hosting account so I can't install isapi filters on the server.
Does it sound like something that could be done by writing an HTTPModule?
I've considered 301 redirect instead but am concerned about google ranking problems.

A .NET HttpModule cannot forward requests to Classic ASP in II6 because of the way the pipeline works. By the time your .NET module executes, you are in the ASP.NET handler and cannot transfer to the ASP handler.
IIS7 has the Integrated Pipeline, which would allow you to have a .NET HttpModule re-write the request to the Classic ASP handler.
You could have a custom 404 handler that clears the 404 status from the response and does a Server.Transfer or Server.Execute your page. The only thing is that you can't pass querystring parameters, so you page would need to parse the request and pull out the variables by hand.
I use a modified version of Smart404 to handle SEO friendly urls, moved files, etc. They call the feature "virtual_aliases".

Related

IIS URL Rewrite custom module doesn't work when used with ARR

I have developed two custom rewrite modules. This is the first time I am doing custom rewrite modules.
When used in classic URL rewrite engine (IIS Server Win 2019 with latest URL rewrite engine) it works without problems, if there are problems I have some custom logging to solve it.
I now need to use it with ARR (Application Request Routing).
It won't even initialize the custom provider, and when I try a rule with custom provider I just get an error 500.
Failed Request Tracing which is best tool to solve this has no concrete errors about this in log.
Are custom URL rewrite providers supported in combination with ARR ?

How exactly are URLs mapped to handlers in IIS 7+

I have a website that uses a ReverseProxy (Helicon APE) to forward some requests to external sources. To achieve this it replaces/adds the extension .apehandler to the URL, so the Helicon APE Handler executes the request.
/ext/app1.aspx is rewritten to /ext/app1.apehandler
This works fine.
When the URL does not end in an extension, there is a problem:
/ext/app2.aspx/something is rewritten to /ext/app2.aspx/something.apehandler
This leads to URLs with two extensions.
If in the handlermapping order .apehandler is defined BEFORE .aspx all is fine.
But when .apehandler is defined AFTER .aspx the PageHandlerFactory-Handler (.aspx Handler) takes over and this results in a 404 error.
In the Failed Request Log the URL_CHANGED entry is the same in both cases, but the HANDLER_CHANGED maps to different handlers.
Maybe there is a small problem in how IIS maps URLs to Handlers in this special case?
My guess is when IIS parses the URLs to map to the handler, matching URLs with two or more extensions goes wrong.
URL /ext/app2.aspx/something.apehandler
IIS parses for .aspx , (wrongly?) finds it in above URL and executes the .aspx Handler
Any ideas?
swobi
Your guess is wrong.
When /ext/app2.aspx/something.apehandler is seen by IIS, it passes path_info of /somthing.apehandler to /ext/app2.aspx. Of course then .aspx handler is called to process it, not the Helicon APE Handler.
It is not just IIS, but all web frameworks that must handle path_info that way. You can find a PHP reference here

How to capture all http requests in a classic asp application?

I need to capture all HTTP requests in a classic ASP application. I looked at Global.asa, but it doesn't have any event that fires for all HTTP requests. Please let me know if I can even do that. Thanks!
You write an ASP script (I call it "redirect.asp" for now) that does all the checks and redirects. Then you have some options:
1.) it in every existing .asp file
2.) Server.Execute "redirect.asp" before other code in every .asp file
3.) Make a rewrite rule, that redirects ALL requests to your redirect.asp
Yes, by writing a function global.asa and abandoning session before redirect did the trick!

Redirection doesn't work from ARR but works within DNN

We have an IIS web farm, of which consisting an load balancer, 4 ARRs, and 2 ASP.NET application servers running DNN CMS. The 4 ARRs will URL rewrite to DNN application servers. We have more than 100 URLs that need to be redirected into more specific resources within the website.
For example, when a user types in http://www.abcd.com/product1 from outside, the desired outcome is to redirect to www.abcd.com/index.aspx?articleid=1234 , we have configured such behavior within DNN environment, and we can sure that it works, as when we browse the site within the DNN application server, the DNN is able to detect the URL and perform redirection accordingly.
Problem occurs when we attempt to browse the http://www.abcd.com/product1 from LB and ARRs, when we type http://www.abcd.com/product1, it simply go back to http://www.abcd.com mainpage, which the redirection doesn't work at all. No IIS level HTTP redirection has been performed at the ARRs and LBs, the only setting is the default URL rewrite rule which will rewrite the URL to backend DNN servers.
Same question has been posted in IIS forum as well, it is just that I decided to post it here again to gain more exposure.
When going through the ARR are you calling off to the specific IP? For example does http://www.abcd.com/product1 become http://xxx.xxx.xxx.xxx/product1 by chance?
If so, you might want to add those as additional portal aliases to the DNN site.
Otherwise, you will might want to use something like Fiddler to see exactly what is going on with redirects/responses.

How to implement URL rewrite in classic ASP using custom 404 page?

My web host told me that they are using Windows IIS (not sure about the version) and are unable to implement a URL rewrite for me. I am now looking at alternative ways to do this. Obviously, I don't have access to the IIS server. I read somewhere that using a custom 404 page, I am able to implement a URL rewrite from my end using classic ASP.
I want to do a URL rewrite for subdomain.mydomain.com to www.mydomain.com/subdomain.
I am a bit lost about the steps that must be taken to implement URL rewrite. Can someone take me through the steps?
Thanks
Request.ServerVariables("HTTP_HOST") will give you the subdomain.
if Request.ServerVariables("HTTP_HOST")="subdomain.domain.com" then
response.redirect("http://domain.com/subdomain")
end if
You can get URL Rewriting on IIS6 with IIRF - it's free. If your web host can install it for you., it's easy to get rewrites on IIS. If the web host has IIS7 or later, then they can use the URL Rewriting module that's included in IIS7.

Resources