Sign in to follow this  

[web] [solved] httpModules, 404s, and ASP.NET

This topic is 3580 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a website whose content is composed entirely from a httpModule. The web.config is as shown.
<configuration>
	<appSettings/>
	<connectionStrings/>
	<system.web>
		<compilation debug="true"/>
		<authentication mode="Windows"/>
    <httpModules>
      <add name="FrostHooker" type="FrostHooker"/>
    </httpModules>    
	</system.web>
</configuration>



The FrostHooker looks like this,
public class FrostHooker : IHttpModule
{
    public FrostHooker()
    {
    }
    public String ModuleName
    {
        get { return "FrostHooker"; }
    }
    public void Init(HttpApplication TheApplication)
    {        
        TheApplication.BeginRequest += 
            (new EventHandler(this.Application_BeginRequest));
    }
    private void Application_BeginRequest(Object TheSource, EventArgs TheEvents)
    {
        string TheRequestString = ((HttpApplication)TheSource).Request.Path.ToLower();
        if (TheRequestString.Contains(".css") ||
            TheRequestString.Contains(".png") ||
            TheRequestString.Contains(".ico"))
        { }
        else
        {
            MWeb TheWebsite = new MWeb((HttpApplication)TheSource);
            TheWebsite.Main();
        }
    }
    public void Dispose()
    {
    }
}



When the user requests "/Website/" (the default page of ASP.NET) everything goes well. However, when the user requests something like "/Website/Library" the output is:
Server Error in '/Website' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

Requested URL: /Website/Library

Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433



Despite that FrostHooker was sucessfully called; Response.Write() was writing the page, not that error. So why is that error appearing?

Share this post


Link to post
Share on other sites
Nevermind, I found it (I think).

With Default.htm, after it handled the HTTPModule it End()'d the response. But with "/Library" there was not subsequent "Library.htm", and so nothing End()'d the response.

I changed my MWeb application to call Response.End() after it's done, and it seems to have fixed it up.

Share this post


Link to post
Share on other sites

This topic is 3580 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this