问题描述
我有一个简单的 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;
}
当我用断点运行这段代码时,我发现这个模块甚至被像图像、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-integration-with-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.
推荐答案
好像有办法解决
http://learn.iis.net/page.aspx/121/iis-70-modules-overview/#Disabling
设置 preCondition="managedHandler"
和 <modules runAllManagedModulesForAllRequests="false"/>
就可以了
setting preCondition="managedHandler"
and <modules runAllManagedModulesForAllRequests="false" />
would do the trick
自我说明:http://code.google.com/p/talifun-web/wiki/静态文件处理程序需要探索这个StaticFileHandler
note to self: http://code.google.com/p/talifun-web/wiki/StaticFileHandler need to explore this StaticFileHandler
参考:
http://learn.iis.net/page.aspx/244/how-to-take-advantage-of-the-iis7-integrated-pipeline/
排除 HttpModule 在 IIS7 上运行静态内容一个>
BUG:IIS7 托管请求
http://msdn.microsoft.com/en-us/library/bya7fh0a.aspx
这篇关于JS、图像和 CSS 被 HTTPModule 拦截的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!