HttpHandler to override IIS

S

Sean

Hi all,

Is it possible to use a custom HttpHandler to handler request that does not
provide a specified page?
e.g. http://www.aaa.com/there/is/no/such/document

I tried to handle this request using a custom HttpModule, but IIS directs
the request to an error page(404 file not found) before delegating to
ASP.NET.

Regards
Sean
 
T

Teemu Keiski

Hi,

it is...

one way is that you need to map all (*) requests to ASP.NET
(aspnet_isapi.dll) to do this. On web site choose Configuration and there
just specify application mappings for files/extensions which will be
processed by ASP.NET. In this case, you'd want to map them all to ASP.NET.
Note that it might cause quite performance penalty when files normally not
needed to be processed are now processed by ASP.NET.

Another way would be specifying a redirection in IIS for 404 error, and put
IIS to redirect to an ASP.NET page in this case. That can be set from Custom
errors tab for the web site / directory.
 
G

Guest

Hi

In your web.config file add the following

<?xml version="1.0" encoding="utf-8" ?><configuration><system.web><customErrors mode="On" defaultRedirect="myerror.aspx"/><error statusCode="404" redirect="404.aspx" /><error statusCode="500" redirect="500.aspx" /><!-- etc... --></system.web></configuration>

Yama Kamya
 
J

Jim Hughes

That will only work for file extensions that are processed by ASP.Net.

If a user types in a url like mypage.htm or mydoc.pdf, IIS will use it's
settings and the web.config info will not be processed.

Yama said:
Hi,

In your web.config file add the following:

<?xml version="1.0" encoding="utf-8"
?><configuration><system.web><customErrors mode="On"
defaultRedirect="myerror.aspx"/><error statusCode="404" redirect="404.aspx"
 
J

John Timney \(Microsoft MVP\)

It sounds like your falling foul of the * mapping in your application and
IIS is therefore not processing the unknown path request via the
aspnet_isapi.dll. In theory IIS does not know what to process as it works
on the principle of file extensions. You can solve it with a very small
iHTTPModule to intercept requests to your web application.

In your module begin_request event (might need to check this event) check
the request path contains an extension, if not deal with it by giving it one
that IIS will recognise (like default.aspx). As the module is in the ISAPI
pipeline, you can intercept the request before it gets processed by asp.net
as a file, and seen as an unknown file type.

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
----------------------------------------------------------------------------
------------------------------------
<blatant plug>
Professional .NET for Java Developers with C#- ISBN: 1-861007-91-4
Professional Windows Forms - ISBN: 1861005547
Professional JSP 2nd Edition - ISBN: 1861004958
Professional JSP - ISBN:
1861003625
Beginning JSP Web Development - ISBN: 1861002092
</blatant plug>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top