JS,图片和CSS过得去的HttpModule截获 [英] JS,Images and CSS getting intercepted by HTTPModule

查看:149
本文介绍了JS,图片和CSS过得去的HttpModule截获的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的HttpModule,做一些自定义会话状态管理。

I have a simple HTTPModule which does some custom session state management.

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;
        }

当我跑这code断点,我看到这个模块调用得到即使是像图片,JS和CSS静态文件。有没有人遇到过这个?我想到的是HTTP模块只挂钩上的HTTP管道的asp.net页面事件。难道他们也勾上静态资源?或者是它只是卡西尼?

When I ran this code with breakpoints, I saw that this module got invoked even for static files like images,js and css. Has anyone experienced this ? I am thinking HTTP modules were only hooking on to events in the http pipeline for asp.net pages . Do they also hook on to static resources ? Or is it just with cassini ?

环境:VS2008 - 卡西尼服务器

Environment: VS2008 - cassini server

PS:我与Win2k8 IIS7在我们的沙箱(还挺新)尝试,并试图将其写入到一个日志文件(因为我们没有VS那里),但不能写入日志文件。相信它的一些写权限的问题。任何人都可以点我的一些资源,它告诉我W2K8与IIS7运行ASP.net时如何设置写权限的目录

PS: I did try it with Win2k8 IIS7 in our sandbox (kinda new), and tried to write it to a log file (as we do not have VS there),but could not write to the log file. Am sure its some write permissions issue. Can anyone point me to some resource which tells me how to set write permissions for directories when running ASP.net with IIS7 in W2k8

EDIT1:据我了解,使用集成管道将延伸HTTP管道静态和管理资源的一致好评
http://aspnet.4guysfromrolla.com/articles/122408-1.aspx http://learn.iis.net/page.aspx / 243 / ASPNET集成与 - IIS7 /

I understand that using Integrated pipeline would extend the http pipelines for static and managed resources alike http://aspnet.4guysfromrolla.com/articles/122408-1.aspx and http://learn.iis.net/page.aspx/243/aspnet-integration-with-iis7/

我们使用的是在我们的督促经典的管道。但还是希望了解其他人都经历过。

We are using classic pipeline in our prod. But still interested in knowing what other people have experienced.

问题2:在集成模式下使用IIS7,是否会降低性能?假设你有几个模块的挂钩与管道,多少是对性能的影响?将是很好,如果有人可以点我为此做了一些基础研究。

Question2: Using IIS7 in integrated mode, will it decrease performance ? Say you have couple of modules hooking up with the pipeline, how much would be the performance impact? Would be nice if some one can point me to some baseline studies done for this.

推荐答案

看起来是有办法做到这一点。

Looks like there is a way to do it

<一个href=\"http://learn.iis.net/page.aspx/121/iis-70-modules-overview/#Disabling\">http://learn.iis.net/page.aspx/121/iis-70-modules-overview/#Disabling

设置 preCondition =managedHandler&LT;模块runAllManagedModulesForAllRequests =FALSE/&GT; 会做的伎俩

请注意自我:
<一href=\"http://$c$c.google.com/p/talifun-web/wiki/StaticFileHandler\">http://$c$c.google.com/p/talifun-web/wiki/StaticFileHandler
需要探索这个StaticFileHandler

note to self: http://code.google.com/p/talifun-web/wiki/StaticFileHandler need to explore this StaticFileHandler

引用

<一个href=\"http://learn.iis.net/page.aspx/244/how-to-take-advantage-of-the-iis7-integrated-pipeline/\">http://learn.iis.net/page.aspx/244/how-to-take-advantage-of-the-iis7-integrated-pipeline/

<一个href=\"http://stackoverflow.com/questions/1156186/exclude-httpmodule-from-running-for-static-content-on-iis7\">http://stackoverflow.com/questions/1156186/exclude-httpmodule-from-running-for-static-content-on-iis7

<一个href=\"http://stackoverflow.com/questions/1267409/bug-iis7-managed-requests\">http://stackoverflow.com/questions/1267409/bug-iis7-managed-requests

<一个href=\"http://msdn.microsoft.com/en-us/library/bya7fh0a.aspx\">http://msdn.microsoft.com/en-us/library/bya7fh0a.aspx

这篇关于JS,图片和CSS过得去的HttpModule截获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆