0

I'm developing an IIS module that is supposed to be triggered when a request is made to all kind of pages on my webserver (managed and unmanaged). To accomplish that I implemented the IHttpModule interface that has a method called HandleRequest which have to be implemented. In the method context I have access to an HttpApplication object and HttpContext object. Is there any indication in these objects or any other place to tell if the request that is now being handled by the module was issued to a managed page (e.g aspx,asmx,web-api,mvc,wcf) or to an unmanaged page (e.g jpg,css,htm..).

Here is the code:

public class MyPreIISReqeustModule : System.Web.IHttpModule
{
  public void Dispose()
    {

    }

  public void Init(HttpApplication context)
    {
        context.BeginRequest += new EventHandler(HandleRequest);
    }
  protected void HandleRequest(Object sender, EventArgs e)
    {
        if (managed_page_request)
           {......}
        else
           {......}
    }
 }
mason
  • 31,774
  • 10
  • 77
  • 121
Ben Guri
  • 306
  • 3
  • 12
  • Does this make sense ? I mean, if managed code is code that runs under the CLR, and the code above ALWAYS runs under the CLR, this program will always be managed... ? – Veverke Jul 15 '15 at 14:33
  • I have to be able to make this distinction between resources that have to be returned immediately, and calls to web-services, and other managed handlers, for reasons of logging,caching and etc. knowing which page doesn't have code behind it will help me avoid unnecessary processing work. – Ben Guri Jul 15 '15 at 14:46
  • I don't know, I am not familiar with this topic. I just thought aloud. – Veverke Jul 15 '15 at 14:48
  • I think you are using the term `managed` incorrectly. Managed means that the code offers garbage collection, runtime checking, reference checks etc. See [Difference between “managed” and “unmanaged”](http://stackoverflow.com/questions/3563870/difference-between-managed-and-unmanaged). I think you need to pick a more appropriate term in your question to avoid confusion. – mason Jul 15 '15 at 14:51
  • under the context of asp.net this term describes my needs accurately. this term is also used by official iis/asp.net documentation to make the same distinction about the behavior of the entities that iis exposes to the client. – Ben Guri Jul 15 '15 at 14:58

0 Answers0