locked
HttpModules on non-ASP.NET files? RRS feed

  • Question

  • User1542577763 posted

    I wrote a simple HttpModule to do authorisation checking.

    This works fine on .aspx files. However, when I extend this to .HTM files (by modifying Application mappings in the virtual directory) ,  IIS is unable to display .HTM files.


     It the <HttpModules> are removed from web.config, IIS is able to serve .HTM files.

    Any idea what's wrong? [:(] 

    1    using System;
    2    using System.Web;
    3    using System.Collections;
    4    using System.ComponentModel;
    5    using System.Text.RegularExpressions;
    6    
    7    
    8    namespace CookieCheckModule
    9    {
    10   	public class ValidateCookie : IHttpModule
    11   	{
    12   		public ValidateCookie()
    13   		{
    14   		}
    15   
    16   		public void Init(System.Web.HttpApplication Appl)
    17   		{
    18   			Appl.BeginRequest += new System.EventHandler(OnBeginRequest);
    19   		}
    20   
    21   		public void Dispose()
    22   		{
    23   		}
    24   
    25   		public void OnBeginRequest(object sender, EventArgs e)
    26   		{
    27   			// get the current HttpContext handler
    28   			HttpApplication app = (HttpApplication)sender;
    29   
    30   		}
    31   
    32   	}
    33   }
    

      

     

    Monday, October 9, 2006 7:46 AM

Answers

  • User-1469150719 posted

    So you're registering all .htm pages to be rendered with asp.net?  If the ISAPI filter for asp.net gets loaded properly for .html then your request WILL go through the HttpModule.  IIS is giving 200, which means that it is ready to serve the page.  Can you test this on your local machine and set a breakpoint in your httpmodule, then call it from a .html page.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 11, 2006 5:43 PM
  • User1542577763 posted

    Thanks for the pointer. Why didn't I think of that? [:P]

     
    My OnBeginRequest() is being called continuously, i.e. the HTTP module went into a infinite loop.

    I resolved this by modifying it to include a call to context.Response.Write() as follows

     

    1    public void OnBeginRequest(object sender, EventArgs e)
    2    {
    3    HttpApplication app = (HttpApplication)sender;
    4    HttpContext context = app.Context;
    5    context.Response.Write(" ");
    6    }
    
     

    The behaviour is not very consistent. Guess I will live with this for now.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 12, 2006 3:07 AM

All replies

  • User371668647 posted
    When you say "unable to display .HTM files", what are you seeing happen?
    Monday, October 9, 2006 12:32 PM
  • User1542577763 posted

    IE gives me an "The Page Cannot be displayed" message.

    There are no entries in the event log. IIS logs show status 200.

    Monday, October 9, 2006 8:30 PM
  • User-1469150719 posted

    So you're registering all .htm pages to be rendered with asp.net?  If the ISAPI filter for asp.net gets loaded properly for .html then your request WILL go through the HttpModule.  IIS is giving 200, which means that it is ready to serve the page.  Can you test this on your local machine and set a breakpoint in your httpmodule, then call it from a .html page.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 11, 2006 5:43 PM
  • User1542577763 posted

    Thanks for the pointer. Why didn't I think of that? [:P]

     
    My OnBeginRequest() is being called continuously, i.e. the HTTP module went into a infinite loop.

    I resolved this by modifying it to include a call to context.Response.Write() as follows

     

    1    public void OnBeginRequest(object sender, EventArgs e)
    2    {
    3    HttpApplication app = (HttpApplication)sender;
    4    HttpContext context = app.Context;
    5    context.Response.Write(" ");
    6    }
    
     

    The behaviour is not very consistent. Guess I will live with this for now.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 12, 2006 3:07 AM