Last post Oct 12, 2006 03:07 AM by MikeLim
Oct 09, 2006 07:46 AM|MikeLim|LINK
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;
8 namespace CookieCheckModule
10 public class ValidateCookie : IHttpModule
12 public ValidateCookie()
16 public void Init(System.Web.HttpApplication Appl)
18 Appl.BeginRequest += new System.EventHandler(OnBeginRequest);
21 public void Dispose()
25 public void OnBeginRequest(object sender, EventArgs e)
27 // get the current HttpContext handler
28 HttpApplication app = (HttpApplication)sender;
Oct 09, 2006 12:32 PM|stiletto|LINK
Oct 09, 2006 08:30 PM|MikeLim|LINK
IE gives me an "The Page Cannot be displayed" message.
There are no entries in the event log. IIS logs show status 200.
Oct 11, 2006 05:43 PM|subdigital|LINK
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.
Oct 12, 2006 03:07 AM|MikeLim|LINK
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)
3 HttpApplication app = (HttpApplication)sender;
4 HttpContext context = app.Context;
5 context.Response.Write(" ");
The behaviour is not very consistent. Guess I will live with this for now.