How to prevent a request being sent to aspnet_wp

  • Thread starter Thread starter Atul
  • Start date Start date
A

Atul

Hi,

We are using a web application developed using ASP.net, When user
requests any .aspx page, first IIS receives that request & forwards
that request to aspnet_wp. On a certain condition, I want to prevent
this request(request of .aspx) being forwarded to aspnet_wp.
Is it possible?

Note: On a certain condition...if that condition is true, if user
requests .aspx page, then that .aspx request should get passed to
aspnet_wp.
but if that condition is set to false, .aspx request should not get
passed to aspnet_wp. Condition can be altered at runtime.

Condition can be like this: on hard-disk, at a particular folder
location if *.htm file exists, then condition is set to true, else
false.

Pls let me know if it is possible.

Thanx and regards
Atul
 
I'm sure there are more experienced IIS and ASPX dev ppl out there who can
answer, but I would like to take a shot at this.

I have one question before I start. If you want to protect your server from
..HTM files, those aren't natively handled by ASPX, but are served up by IIS.
You would have had to do some work with adding the .htm (and maybe even
..html) as extensions to your IIS Configuration mappings and have them
forwarded onto the ASPNET_isapi.dll. That's an explicit operation. I was
just playing with this exact thing this week.

If you want to do some "logic" with conditions, then it does indeed sound
like you want to have ASPX (sorry, when I say ASPX I mean the
ASPNET_isapi.dll, the .net piece of IIS :>) handle the requests for you. Is
there a problem with this? If you want to handle/reject a specific url
pattern, you probably want to look at either IHttpHandler or IHttpModules.
Again, I was playing with the IHttpHandler this week and even for me, it's
not that complicated to setup. MUCH easier than it is with j2ee, servlets
and url mappings. :> You only need to change one web.config file (add your
url mapping) and implement the IHttpHandler interface. If you need a lower
level Http url handling, then that means you probably want to look at the
IHttpModule interface.

Having said all that, too many options eh? sorry about that. There is one
more thing to look at. In IIS, under the Configurations button, look at the
proper extension you want to handle (.htm or .html), if it's there, you'll
see a checkbox at the bottom for if file exists (not the right text but
something like that). Maybe that option is something you can use if you
only want IIS to handle that type of file without it getting to ASPX?

HTH?! Good luck.
 
Flip,
Thanx for the solution.



Now I will explain my work condition:
1. We have our website developed using ASP.Net.
2. When IIS is reset OR ASP.Net process is recycled...then for the
first (.aspx)request all .Net files gets compiled.
3. But virtual directory's bin folder contains lot of dlls..time
required to compile the .net dlls (MSIL -> Native code) is very high.
4. During this time, if any client requests .aspx page...then he has
to wait a lot.
5. So during this time if any .aspx request comes...I don't want it to
be get processd by ASPNET_isapi.dll. IIS should not forward this
request to ASPNET_isapi.dll, so user don'r have to wait a lot for
getting response.
6. Once all dlls are compiled in memory...IIS will start forwarding
requests to ASPNET_isapi.dll.

So I want to know is this possible...for the first request when dlls
are getting compiled...IIS will not forward request...and for next
requests it will start forwarding .aspx requests to ASPNET_isapi.dll.

Thanx & Regards
Atul
 
2. When IIS is reset OR ASP.Net process is recycled...then for the
first (.aspx)request all .Net files gets compiled.
I believe there is a setting you can adjust (which I believe ppl on the web
recommend) to increase the time between those recycling of the sessions. I
do have that problem on my server, every 20m the aspx worker thread
restarts/recycles itself and I have to wait for the recompilation. :< I
wish there were a way like in J2EE where you could keep the compiled code?!
I don't mind the restart of the thread (protects against DOS), but it seems
to lose the compiled code. :< Increasing the number, in w2k3server it's in
the thread pool I believe.
3. But virtual directory's bin folder contains lot of dlls..time
required to compile the .net dlls (MSIL -> Native code) is very high.
There HAS to be a way to keep the compiled code? The more I think of it,
the more I'm convinced there HAS to be a way if j2ee can do it, .net should
be able too! I hope someone else is watching and can help us?
5. So during this time if any .aspx request comes...I don't want it to
be get processd by ASPNET_isapi.dll. IIS should not forward this
The problem is to forward the requests, you need to have aspnet_isapi.dll
running, so what you're asking is to have aspx handle the request but also
ignore it. There's a complicated process/solution in there! :> haha
So I want to know is this possible...for the first request when dlls
are getting compiled...IIS will not forward request...and for next
requests it will start forwarding .aspx requests to ASPNET_isapi.dll.
It sounds like you might want to do one of two things.
1-create a small separate web app which acts like your traffic cop and if
the main web app is running/loaded/not compiling, then you forward the
requests to it, otherwise, pass back html that says sorry, server busy at
this time.
2-have an IHttpModule which processes everything first and somehow get into
the IIS pipeline to see if the page is currently compiling or not? I'm not
sure how you would do that though? :<

Is there any reason why you don't want the user to wait while the page
compiles?

There are two other solutions, but a bit more unorthodox
3-have an html layer/div/span (not sure which one sorry :<) which says
Please wait ... and the html will hide that after the page is done loading
4-bump up the value that tells IIS when to recycle/recompile the page to
maybe only once a day?
 
Back
Top