473,322 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

HttpHandler to override IIS

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
Nov 18 '05 #1
4 2887
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.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

"Sean" <se**@hotmail.com> wrote in message
news:uT****************@TK2MSFTNGP10.phx.gbl...
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

Nov 18 '05 #2
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
Nov 18 '05 #3
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" <an*******@discussions.microsoft.com> wrote in message
news:89**********************************@microsof t.com...
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 Kamyar

Nov 18 '05 #4
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>
----------------------------------------------------------------------------
------------------------------------

"Sean" <se**@hotmail.com> wrote in message
news:uT**************@TK2MSFTNGP10.phx.gbl...
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

Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Hanse Davion | last post by:
Can anyone provide some insight on what this problem could be? I have searched the web, read forums, and all the installation documentation for the dotnetnuke feeware portal from asp.net. I am...
3
by: Jed | last post by:
I have written an HttpHandler which I invoke through an ashx page. The HttpHandler does various things to process the request, then it is supposed to redirect to a confirmation page. Everything...
4
by: Jeremy Lew | last post by:
When my HttpHandler is processing a request when installed on a particular 2003 Server machine, the Context.Session object is null. Any idea why this might be? My handler implements...
2
by: rpale | last post by:
We want to create server-side code that will retrieve the user requested pages, then manipulate the content of those pages just before being sent back to the user. We tried the following: ...
7
by: Adam | last post by:
Im trying to add an httphandler for all *.sgf file extensions. I have developed the handler, 1. installed it into the gac 2. added it to the machine.config: <httpHandlers> <add verb="*"...
0
by: pamelafluente | last post by:
I have implemented an example of HttpHandler to talk with my Windows application running on the server. I want to send some command (to do something) from IE (client) to my program running on...
4
by: =?Utf-8?B?S2V2aW4=?= | last post by:
I have an HttpHandler installed on a server in the GAC that I want to grant public access to across all sites on the server. The problem I have is that some sites use forms authentication. For...
5
by: zlf | last post by:
Hello, I try to use a custom HttpHandler to add something to session, then display the original page. public void ProcessRequest(HttpContext context) { context.Session = "test"; } But, a...
1
by: Joseph Geretz | last post by:
If an HttpHandler is implementing IsReusable = true, is the instance notitifed when it is actually released to the pool? Of course, each instance is released to the pool when ProcessRequest...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.