JS,图像和CSS被HTTPModule拦截

时间:2010-01-21 20:42:54

标签: asp.net iis-7 httpmodule cassini ihttpmodule

我有一个简单的HTTPModule,可以进行一些自定义会话状态管理。

public void Init(HttpApplication context)
        {
            context.AcquireRequestState += new EventHandler(ProcessBeginRequest);
            ActivityLogger.LogInfo( DateTime.UtcNow.ToLongTimeString() + " In Init " + HttpContext.Current.Request.Url.AbsoluteUri);
        }

public void ProcessBeginRequest(object sender, EventArgs e)
        {
            HttpApplication application = sender as HttpApplication;
            ActivityLogger.LogInfo(DateTime.UtcNow.ToLongTimeString() + " In ProcessBeginRequest ");
            if (application != null)
            {
                string requestURL = application.Context.Request.Url.ToString();
                ActivityLogger.LogInfo(DateTime.UtcNow.ToLongTimeString() + " In ProcessBeginRequest " + requestURL);
            }
            return;
        }

当我使用断点运行此代码时,我看到即使对于静态文件(如images,js和css)也调用了此模块。有没有人经历过这个?我认为HTTP模块只是挂钩到asp.net页面的http管道中的事件。他们是否也依赖于静态资源?或者只是卡西尼?

环境:VS2008 - cassini服务器

PS:我在我们的沙盒中尝试使用Win2k8 IIS7(有点新),并尝试将其写入日志文件(因为我们没有VS),但无法写入日志文件。我确定它的一些写权限问题。任何人都可以指向我一些资源,告诉我如何在W2k8中使用IIS7运行ASP.net时为目录设置写权限

Edit1:我知道使用Integrated管道会扩展静态和托管资源的http管道 http://aspnet.4guysfromrolla.com/articles/122408-1.aspxhttp://learn.iis.net/page.aspx/243/aspnet-integration-with-iis7/

我们在生产中使用经典管道。但仍然有兴趣了解其他人的经历。

问题2:在集成模式下使用IIS7会降低性能吗?假设您有几个模块与管道连接,性能影响有多大?如果有人可以指出我为此做了一些基线研究,那就太好了。

2 个答案:

答案 0 :(得分:13)

答案 1 :(得分:0)

是的,它将被调用任何类型的文件。

在这些模块中,通常会过滤掉您不感兴趣的任何内容。通过检查HttpContext.Request.Url.AbsolutePath是否包含SharePoint下的“/ _layouts”。