WHEN STATICFILEHANDLER IS NOT STATICFILEHANDLER
I could also have called this "wildcard .NET mapping in IIS Express from web.config."
I'm sure that, like, everyone out there but me has figured this out by now, but... well, I'll blog it anyway.
Problem: Your ASP.NET web site has a VirtualPathProvider that serves static files (e.g., .jpg, .css, etc.). It works great in the Visual Studio development web server but switching to IIS Express, it suddenly doesn't work.
My team has just such a provider that serves static files out of embedded resources. We switched from Cassini over to IIS Express and couldn't for the life of us figure out why it suddenly stopped working. I mean, it's "integrated pipeline," right? WTF?
OK, so my first "duh!" moment was when I realized that it's integrated pipeline, not ".NET is responsible for handling each request." That is, you have a managed request pipeline but the actual handler that serves the content may or may not be managed. It's one of those things you know, then forget you know, then remember again when you hit a snag.
At that point I went looking in config to see what the handler was for static files and I saw this in the system.webServer/handlers section of applicationhost.config:
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
This is where I made my mistake. I know what the line there says, but in my mind, I read it as "Use the StaticFileHandler for any files not previously mentioned." So I'm thinking System.Web.StaticFileHandler, right? It's integrated, so that's your built-in wildcard mapping... right?
That's not what it says.
It says, "When all else fails, use the unmanaged default mechanism to serve up the static content." Which, further, means "skip all VirtualPathProviders and go right to disk."
My teammate, Sagar, figured that one out and we were both slapping our foreheads. Of course. Again, integrated pipeline, not ".NET handles all requests."
The fix is to add the .NET static file handler back into your pipeline. You can do this in your web.config in system.webServer/handlers:
<add name="AspNetStaticFileHandler" path="*" verb="*" type="System.Web.StaticFileHandler" />
We did that, and suddenly things were working again. Bam! Done.
Note that doing this has some performance and caching implications. The unmanaged, standard IIS static file handler is pretty well optimized for performance; more so than the managed static file handler. Also, the managed static file handler doesn't write caching-related information (e.g., ETag or Expires headers) for virtual files that are not served up from disk. Something to consider.
WHEN STATICFILEHANDLER IS NOT STATICFILEHANDLER的更多相关文章
- Tornado 模板(StaticFileHandler/static_path/template_path等) 笔记
使用StaticFileHandler进行首页默认访问页面,最好将StaticFileHandler放在最后面,这样不会覆盖要匹配自定义的路径 import tornado.web import to ...
- tornado.web.StaticFileHandler
tornado.web.StaticFileHandler 源代码中的解释 class StaticFileHandler(RequestHandler): """A s ...
- Tornado-StaticFileHandler参考
StaticFileHandler ====== tornado.web.StaticFileHandler 源代码中的解释 class StaticFileHandler(RequestHandle ...
- Tornado(cookie、XSRF、用户验证)
--------------------Cookie操作-------------------- 1.设置Cookie 1.set_cookie(name,value,domain=Non ...
- 4.(基础)tornado应用安全与认证
这一节我们介绍应用安全与认证,其实中间省略了一个数据库.对于tornado来说,读取数据库的数据,性能的瓶颈还是在数据库上面.关于数据库,我在<>中介绍了sqlalchemy,这是一个工业 ...
- tornado session
[转]tornado入门 - session cookie 和session 的区别: 1.cookie数据存放在客户的浏览器上,session数据放在服务器上. 2.cookie不是很安全,别人可以 ...
- 分享在winform下实现模块化插件编程-优化版
上一篇<分享在winform下实现模块化插件编程>已经实现了模块化编程,但我认为不够完美,存在以下几个问题: 1.IAppContext中的CreatePlugInForm方法只能依据完整 ...
- MVC项目中,如何访问Views目录下的静态文件!
<!--注意,是system.webServer节点,而非system.web--><system.webServer> <handlers> <add na ...
- tornado学习笔记18 _RequestDispatcher 请求分发器
根据Application的配置,主要负责将客户端的请求分发到具体的RequestHandler.这个类实现了HTTPMessageDelegate接口. 18.1 构造函数 定义: def __in ...
随机推荐
- NOIP初赛 BLESS ALL!
祝初赛顺利!RP++! 下午再写一篇题解来加RP
- delete symlink in subversion using svn delete command
# svn delete etc/systemd/system/getty.target.wants/serial-getty@ttyS3.service@ D etc/systemd ...
- bzoj1084&&洛谷2331[SCOI2005]最大子矩阵
题解: 分类讨论 当m=1的时候,很简单的dp,这里就不再复述了 当m=2的时候,设dp[i][j][k]表示有k个子矩阵,第一列有i个,第二列有j个 然后枚举一下当前子矩阵,状态转移 代码: #in ...
- pymssql
用与连接sql server数据库的python接口 import pymssql 1.配置信息 conf={ "host": "118.190.41.846:9099& ...
- 玩转X-CTR100 l STM32F4 l PS2无线手柄-4WD智能小车
我造轮子,你造车,创客一起造起来!更多塔克创新资讯[塔克社区 www.xtark.cn ][塔克博客 www.cnblogs.com/xtark/ ] 前面已介绍X-CTR100控制器解码PS2无线手 ...
- 福大软工1816 - 第八次作业(课堂实战)- 项目UML设计
团队 学号 姓名 本次作业博客链接 031602428 苏路明(组长) https://www.cnblogs.com/Sulumer/p/9822854.html 031602401 陈瀚霖 htt ...
- Enginering English for interview (1)
I was lucky to work in a foreign company, Here is an overview of the interview test : 1.Because of t ...
- Oracle中varchar2类型字段长度限制使用问题
为纪念中华人民共和国建军90周年,特此一篇,以此纪念,我军威武!!! 一.问题背景 项目中商品发布,却没有保存成功. 二.问题定位 初步判断向数据库中保存时出现了错误,查看日志文件,由于日志文件过大就 ...
- arpg网页游戏特效播放(一)
网页游戏中的特效,主要包括:场景特效,攻击特效和UI特效三种.场景特效是在地图层上播放的特效,攻击特效主要是技能触发的一些特效,UI特效是面板上的一些特效,还有一些在人物身上播放的特效,例如脚底光圈特 ...
- C语言指针使用小记 (深入理解C指针 读后小记)
最近正值过年在家,新年初一,闲暇时间无事可做便把以前看过的书籍整理了一下,顺手也把这本“深入理解C指针”的书重新读了一遍,这本书总体感觉比较简单,但是还是不免有些地方是平时没有想到过或者没有注意到的, ...