Jump to content
  • Advertisement
Sign in to follow this  
Thevenin

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

This topic is 3792 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!