How can I use the IIS HttpApplication object in a module to detect if the request is a postback? This is for a www / ssl redirecting module so we want to detect whether or not it is postback as soon as possible, preferably before page execution. This code will need to run on IIS6 and IIS7.
I solved this by just checking the request method to see if it was POST instead of GET.
Related
I'm working with MicroStrategy 10.3, hosted on IIS 7.5. I'm using their
URL API to run a document, and change the value of a drop down selector.
IIS is tinkering with my query parameters though, via a 302 redirect. This URL:
https://server/MicroStrategy/asp/Main.aspx?Server=XXX&Project=XXX&evt=2048001&src=Main.aspx.2048001&maxWait=-1&documentID=XXX&evt=2048084&src=Main.aspx.oivm.rwb.2048084&ctlKey=XXX&elemList=hXX;XXX&evtorder=2048001%2c2048084&2048084=1&2048001=1
is being 302'ed to:
https://server/MicroStrategy/asp/Main.aspx?Server=XXX&Project=XXX&evt=2048001%2C2048084&src=Main.aspx.2048001%2CMain.aspx.oivm.rwb.2048084&maxWait=-1&documentID=XXX&ctlKey=XXX&elemList=hXX%3BXXX&evtorder=2048001%2C2048084&2048084=1&2048001=1
(The two distinct evt and src are being combined, and MicroStrategy is complaining that 'Event ID 2048001,2048084 is illegal'.)
Does IIS do this type of thing out of the box? It certainly seems unlikely. I can't see any custom HTTP redirects in IIS Manager for the application.
IIS was most definitely not the culprit.
MicroStrategy was generating the 302 redirect itself, subsequent to an automated login. You would think that an enterprise application wouldn't rewrite its own URL such that it causes an error, but you'd be wrong.
I resolved the issue by manually adding a login event, and URL-encoding the two events I wanted to call into the target key:
https://server/MicroStrategy/asp/Main.aspx?Server=XXX&Project=XXX&evt=3054&src=Main.aspx.3054&target=evt%3D2048001%26src%3DMain.aspx.2048001%26maxWait%3D-1%26documentID%3DXXX%26evt%3D2048084%26src%3DMain.aspx.oivm.rwb.2048084%26ctlKey%3DXXX%26elemList%3DhXX%3BXXX%26evtorder%3D2048001%252c2048084%262048084%3D1%262048001%3D1
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!
I have an IIS rewrite rule that I'm trying to use.
When I set the Action to ‘redirect’ its working fine. Likewise, if I select Custom response and set some arbitrary status code, I’m getting that back in the HTTP response, so I know the rule is matching for my URL. However, I need to rewrite this (to act as a reverse proxy) but as soon as I change the action to ‘Rewrite’ it doesn’t take effect.
I have installed the Application Request Routing Module and enabled the proxy under ‘Server proxy settings’ (as per this page http://www.iis.net/learn/extensions/url-rewrite-module/reverse-proxy-with-url-rewrite-v2-and-application-request-routing).
I’ve tried everything from restarting the site(s), the server, IIS, the W3p process and nothing takes effect. I've added the rule at a server level as required and confirmed in the ApplicationHost.config file that it is there and correct.
Any ideas what isn't causing this to fire?
I've seen a few similar posts here on SO, but none of them either have a solution or work for me in this instance.
EDIT: OK, so if I change the application pool from integrated to classic, the rule seems to fire (which is weird as the rule is at a server level!?!). However, My site requires integrated mode to function. Anyone know whats going on here?
Question for you guys.
If I am capturing a 404 error through an isapi filter in IIS and calling a handler with code to redirect the user by taking in their url request as a parameter and running a query on the database. Can I run into issues making that dynamic server side redirect if multiple users are being caught by the error handler simultaneously. I believe the first execution is being terminated, the second one completes, and both users are redirected to the same url.
Any thoughts?
Thanks
I am capturing a 404 error through an isapi filter in IIS...
I am not clear if you are writing the filter, or if the filter already exists. I'll assume you are writing it yourself since this is stackoverflow, and I'll assume C or C++ since you said ISAPI.
In that case....An ISAPI filter will get an HTTP_FILTER_CONTEXT for each request incoming request. You need to structure your code so as to keep those things separate; pass the pointer to that structure around to each function in your code, if using C, or store it in object state if using C++. Also your code needs to be thread-safe.
Can I run into issues making that dynamic server side redirect if multiple users are being caught by the error handler simultaneously.
Yes, if you don't follow the requirements for writing a multi-threaded filter.
There are simpler ways to accomplish what you want, I think. IIS allows administrators to specify URLs to deliver a "custom HTTP Error Response". The URL can be anything on the webserver, including a dynamic web script, like a page written in ASPNET or PHP or whatever. You may want to use a 302 redirect to your dynamic page; that's a common pattern. There's no need to resort to writing an ISAPI filter.
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".