By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,911 Members | 1,137 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,911 IT Pros & Developers. It's quick & easy.

ISAPI filter or http module

P: n/a
I know I can use http module in my asp.net project to rewrite url. However
that is only true for .aspx page, there are many other static page in my
application such as .htm. .asp, etc.

My question is:
1. Is it possible to map all those request (.gif, .jpg, .swf, .asp, .htm,
whatever) to my http module first?
2. Or in this situation, I have to use a ISAPI filter?
Nov 19 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
Hi,

You could use a HTTPHandler in .net to handle specified requests.

You write your handler (to do whatever you want) then you have to
"register" it in your web.config. In there you specify which requests
to handle. These can be from anything ("*") to just one specific file
("mypage.aspx"). And yes you can handle .gif, .jpg, .swf etc. using
this method.

If you do a search on MSDN you should be able to find a couple of
articles on writing HTTPHandlers.
Regards,

Peter Chadwick (MCP)
pe**@code-explorers.com

Nov 19 '05 #2

P: n/a
Thanks for your quick reply. I will try that.

"Peter Chadwick (MCP)" <pe**@code-explorers.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
Hi,

You could use a HTTPHandler in .net to handle specified requests.

You write your handler (to do whatever you want) then you have to
"register" it in your web.config. In there you specify which requests
to handle. These can be from anything ("*") to just one specific file
("mypage.aspx"). And yes you can handle .gif, .jpg, .swf etc. using
this method.

If you do a search on MSDN you should be able to find a couple of
articles on writing HTTPHandlers.
Regards,

Peter Chadwick (MCP)
pe**@code-explorers.com

Nov 19 '05 #3

P: n/a
You can use an http module if you configure IIS to handle those file-type
requests using ASP.NET.

+ Open IIS Manager
+ Select your website
+ Right-click, Properties
+ Select Home Directory tab
+ Click Configuration... button

You can see the application extension mappings here. Double click on, e.g.
the ".aspx" extension to see how the mapping to ASP.NET is setup.

You can duplicate this for all file types you want to pass through ASP.NET
(and your http module) by Adding / Editing as desired. Add one for .gif,
..jpg, .jpeg, and so on.

Note that on Server 2003 you can also do a wildcard mapping in the lower
listbox, however there are some disadvantages to this. Certain features
"break" such as default webpages. However if you have a very large number
of file types to map, you may want to explore this approach.

/// M
"Guoqi Zheng" <no@sorry.com> wrote in message
news:ef**************@TK2MSFTNGP11.phx.gbl...
I know I can use http module in my asp.net project to rewrite url. However
that is only true for .aspx page, there are many other static page in my
application such as .htm. .asp, etc.

My question is:
1. Is it possible to map all those request (.gif, .jpg, .swf, .asp, .htm,
whatever) to my http module first?
2. Or in this situation, I have to use a ISAPI filter?

Nov 19 '05 #4

P: n/a
Thanks for the replying, I got another problem, however if a direcory
without an file name in it.
such as http://www.mysite.com/aaaa/fakedirectory/

How can I catch this kind of URL?
"Guoqi Zheng" <no@sorry.com> wrote in message
news:ef**************@TK2MSFTNGP11.phx.gbl...
I know I can use http module in my asp.net project to rewrite url. However
that is only true for .aspx page, there are many other static page in my
application such as .htm. .asp, etc.

My question is:
1. Is it possible to map all those request (.gif, .jpg, .swf, .asp, .htm,
whatever) to my http module first?
2. Or in this situation, I have to use a ISAPI filter?

Nov 19 '05 #5

P: n/a
Hi,

This can be handled by specifying the default document in IIS. In the
properties of the website you can supply a list of default documents
(i.e. to try if no file is specified). It starts with files such as
default.htm, default.asp, default.aspx etc. but you can add your own.
Regards,

Peter Chadwick (MCP)
pe**@code-explorers.com

Nov 19 '05 #6

P: n/a
That is what I think, but that does not work like it should be.

I think If I have a directory like http://www.mysite.com/aaaa/bbb/

IIS will check first to make sure whether that directory exists or not
before it load the default.aspx page. That direcotry is fake, so it is not
exists, so IIS return an page not found error.

Any idea?
"Peter Chadwick (MCP)" <pe**@code-explorers.com> wrote in message
news:11********************@z14g2000cwz.googlegrou ps.com...
Hi,

This can be handled by specifying the default document in IIS. In the
properties of the website you can supply a list of default documents
(i.e. to try if no file is specified). It starts with files such as
default.htm, default.asp, default.aspx etc. but you can add your own.
Regards,

Peter Chadwick (MCP)
pe**@code-explorers.com

Nov 19 '05 #7

P: n/a
Hi,

If IIS cannot find one of the default files it will return a page not
found error (because it isn't found).

I'm not really sure why you would want to try and load a page in a
directory that doesn't exist. Are you saying you want to know when a
url specifying a directory that doesn't exist is posted and handle that
in some special way, other than the not found special error?
Regards,

Peter Chadwick (MCP)
pe**@code-explorers.com

Nov 19 '05 #8

P: n/a
I'm not sure that it would work....but I think it will.....

you're having to get around teh fact that IIS intercepts the request and
throws the 404 error PRIOR to the aspnet_pw getting a hold of it.

So, how about creating an ASPX doc and setting that to your custon page for
404 errors in IIS?

I know that this is a little clunky, but the issue here is that you need to
get IIS to get the request to .NET somehow...that's the only way I can think
about it.

I could be wrong, though
"Guoqi Zheng" <no@sorry.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Thanks for the replying, I got another problem, however if a direcory
without an file name in it.
such as http://www.mysite.com/aaaa/fakedirectory/

How can I catch this kind of URL?
"Guoqi Zheng" <no@sorry.com> wrote in message
news:ef**************@TK2MSFTNGP11.phx.gbl...
I know I can use http module in my asp.net project to rewrite url. However that is only true for .aspx page, there are many other static page in my
application such as .htm. .asp, etc.

My question is:
1. Is it possible to map all those request (.gif, .jpg, .swf, .asp, ..htm, whatever) to my http module first?
2. Or in this situation, I have to use a ISAPI filter?


Nov 19 '05 #9

P: n/a
Those direcotry are created by URL rewrite. Those directories are not really
there. That is why I need the URL rewrite http module.

To make the site easily understood by people and search, we change url like
cateogry.aspx?id=2 to xxx/category/1.aspx

Any idea how can do this? Do I really have to use ISAPI filter?

"Peter Chadwick (MCP)" <pe**@code-explorers.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
Hi,

If IIS cannot find one of the default files it will return a page not
found error (because it isn't found).

I'm not really sure why you would want to try and load a page in a
directory that doesn't exist. Are you saying you want to know when a
url specifying a directory that doesn't exist is posted and handle that
in some special way, other than the not found special error?
Regards,

Peter Chadwick (MCP)
pe**@code-explorers.com

Nov 19 '05 #10

P: n/a
Hi,

Map all extensions to aspnet_isapi.dll using the wildcard mapping in server
2003 or '.*' extension in 2000 server, uncheck the 'check if file exists'
checkbox. This will let you intercept requests for folders whether or not
they physically exist.

Ben
http://bitarray.co.uk/ben
"David Jessee" <dj*****@houston.rr.com> wrote in message
news:er**************@tk2msftngp13.phx.gbl...
I'm not sure that it would work....but I think it will.....

you're having to get around teh fact that IIS intercepts the request and
throws the 404 error PRIOR to the aspnet_pw getting a hold of it.

So, how about creating an ASPX doc and setting that to your custon page for 404 errors in IIS?

I know that this is a little clunky, but the issue here is that you need to get IIS to get the request to .NET somehow...that's the only way I can think about it.

I could be wrong, though
"Guoqi Zheng" <no@sorry.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Thanks for the replying, I got another problem, however if a direcory
without an file name in it.
such as http://www.mysite.com/aaaa/fakedirectory/

How can I catch this kind of URL?
"Guoqi Zheng" <no@sorry.com> wrote in message
news:ef**************@TK2MSFTNGP11.phx.gbl...
I know I can use http module in my asp.net project to rewrite url. However that is only true for .aspx page, there are many other static page in my application such as .htm. .asp, etc.

My question is:
1. Is it possible to map all those request (.gif, .jpg, .swf, .asp, .htm, whatever) to my http module first?
2. Or in this situation, I have to use a ISAPI filter?



Nov 19 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.