Print Page | Close Window

How to make IIS ignore 404 errors?

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=10530
Printed Date: 29 March 2026 at 4:24am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: How to make IIS ignore 404 errors?
Posted By: Diep-Vriezer
Subject: How to make IIS ignore 404 errors?
Date Posted: 19 May 2004 at 7:24pm

Hey all, I've made some HttpModules, which can handle stuff like this

  http://site.local/mypage.myfunnyextention - http://site.local/mypage.myfunnyextention

and handle it like a special kind of shortcut. However, the 'page' doesn't really exists. Now, IIS raises a 404 error whenever it gets called, so is there a way to avoid all IIS errors, since I let ASP.NET handle them?

EDIT: OMG, wait. I forgot to hand over all the extentions to ASP.NET
EDIT2: Which doesn't seems to matter =|



-------------
Gone..



Replies:
Posted By: dpyers
Date Posted: 19 May 2004 at 7:44pm
IIIRC, you have to ask your host to map the file extension to the asp.net dll.

-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Diep-Vriezer
Date Posted: 19 May 2004 at 7:56pm
I already added a wildcard to C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dl l, without the 'Verify that file exists' checkbox checked.

-------------
Gone..


Posted By: dpyers
Date Posted: 19 May 2004 at 10:02pm

Sorry, just reread your OP. I assume that if the page does exist, it gets handled by .net ok.

I think IIS checks for the existence of the page before handing it off to aspnet_isapi.dll. If you can set up custom error pages on your host, you could route the 404's to an asp/aspx script for handling.

I don't recall if it was you or Semikolon who use hsphere, but if it was you, you have to be on ver 2.4 to use scripts instead of .htm/.html docs for custom errors.



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: pmormr
Date Posted: 19 May 2004 at 10:30pm

as dp suggested... just set up a custom 404 error page that redirected to your ASP.NET handling page



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: Mart
Date Posted: 20 May 2004 at 2:55am
Hmm strange, I use a similar system and it works perfect, I think your mapping to aspnet_isapi.dll wrong.


Posted By: Diep-Vriezer
Date Posted: 20 May 2004 at 10:03am
Fact is that I do not route stuff to an aspx page, but handle it with a HttpModule. I'm going to rewrite all the things, see if it works then.

-------------
Gone..


Posted By: Diep-Vriezer
Date Posted: 20 May 2004 at 11:12am

Alright, at least IIS leaves the handling to ASP.NET, FrontPage extentions didn't work if you handled over all extentions to ASP.NET, so I got rid of those useless things.

Anyways, now ASP.NET raises a 404 error, and the HttpModule doesn't seem to do anything.



-------------
Gone..


Posted By: Mart
Date Posted: 20 May 2004 at 11:23am
Are you sure you registered it in your web.config file?


Posted By: Diep-Vriezer
Date Posted: 20 May 2004 at 11:40am

Yes. I added a text file with the name Default.dh, and the module handles it. It doesn't seems to handle stuff which isn't there, which means the module is only called whenever ASP.NET doesn't encounter errors. Is there a way to avoid this?

Also, whenever I have a sub which is executed at the begin of the request, and peform this code

HttpContext.Current.Response.ContentType = "text/html"

HttpContext.Current.Response.Write("Request GUID = " & Guid.NewGuid.ToString & " <br><br>")

It still displays the Default.dh file as a text file, rather than a HTML page.

EDIT It might be the cache.
EDIT2 But it wasn't =|



-------------
Gone..


Posted By: Mart
Date Posted: 20 May 2004 at 12:05pm
Can you paste in the <httpHandlers> node of your web.config file in


Posted By: Diep-Vriezer
Date Posted: 20 May 2004 at 12:08pm

<httpModules>

<add type="Root.Components.Security.HttpModule.HttpModule,den Heijer" name="HttpModule" />

</httpModules>

den Heijer.dll is the ouput

--

Namespace Components.Security.HttpModule

Public Class HttpModule

Implements IHttpModule

Public Sub Dispose() Implements System.Web.IHttpModule.Dispose

End Sub

Public Sub Init(ByVal context As System.Web.HttpApplication) Implements System.Web.IHttpModule.Init

AddHandler context.BeginRequest, AddressOf Me.BeginRequest

End Sub

Private Sub BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs)

HttpContext.Current.Response.ContentType = "text/html"

HttpContext.Current.Response.Write("Request GUID = " & Guid.NewGuid.ToString & " <br><br>")

End Sub

End Class

End Namespace



-------------
Gone..


Posted By: Mart
Date Posted: 20 May 2004 at 12:13pm
Try this:

<httpHandlers>
   <add verb="*" path="*.dh" type="Root.Components.Security.HttpModule.HttpModule, den Heijer" />
   </httpHandlers>


Posted By: Diep-Vriezer
Date Posted: 20 May 2004 at 12:44pm
Altough it worked  Thanks! I still don't understand why that module wouldn't work.. Anyway, I set the path to path="*.*" and it will handle pretty much everything.

-------------
Gone..


Posted By: Diep-Vriezer
Date Posted: 20 May 2004 at 1:38pm

Erm, now I have all the extentions handled by that one module, including the .aspx pages

If I would create a new <add verb="*" path="*.aspx" what type="" would I need if I want them to be handled by the original ASP.NET handler?



-------------
Gone..


Posted By: Mart
Date Posted: 20 May 2004 at 2:42pm
From my Machine.config file:

<add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory"/>


Posted By: Mart
Date Posted: 20 May 2004 at 2:44pm
btw you can check out all the others in the following file:

C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CONFIG\machin e.config


Posted By: Diep-Vriezer
Date Posted: 20 May 2004 at 5:43pm

Thanks very much! It just looks really 1337 to have stuff like this

http://www.blep.org/site.blep!weirdencryptedquery - http://www.blep.org/site.blep!weirdencryptedquery or whatever..



-------------
Gone..



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net