为什么我的 HttpHandler 被忽略?
在 ASP.NET 应用程序中,我需要对发送的每个 CSS 文件进行一些更改。
所以我创建了一个 HttpHandler (在应用程序本身内部),添加:
<add verb="*" path="*.css" type="MyWebsite.CssTestHandler,MyWebsite"/>
到 system.web/httpHandlers
中的 Web.config 并修改处理程序,如下所示:
public void ProcessRequest(HttpContext context)
{
context.Response.Clear();
context.Response.Write("Hello World");
context.Response.End();
}
但 CSS 文件仍然像以前一样,所以处理程序只是被忽略。
我做错了什么?
In an ASP.NET application, I need to do some changes on every CSS file sent.
So I created an HttpHandler (inside the app itself), added:
<add verb="*" path="*.css" type="MyWebsite.CssTestHandler,MyWebsite"/>
to Web.config in system.web/httpHandlers
and modified the handler like this:
public void ProcessRequest(HttpContext context)
{
context.Response.Clear();
context.Response.Write("Hello World");
context.Response.End();
}
But CSS files are still just like they were before, so the handler is just ignored.
What I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要在 IIS 中设置通配符映射,请参阅以下链接:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/5c5ae5e0-f4f9-44b0-a743-f4c3a5ff68ec.mspx?mfr=true
这将导致对 CSS 文件的请求由 ASP.NET 而不仅仅是 IIS 提供服务。
如果应用程序提供的流量非常高,请考虑仅为 .css 文件设置此映射,或者最好更改页面中的 CSS 数据而不是更改文件。
You need to setup a wildcard map in IIS, see the following link:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/5c5ae5e0-f4f9-44b0-a743-f4c3a5ff68ec.mspx?mfr=true
This will cause the request for the CSS file to be served by ASP.NET rather than just IIS.
If the application serves very high traffic, consider setting this mapping for .css files only, or even better change the CSS data in the page rather than changing the file.
检查此页面以获取有关所有 3 种 IIS 版本(6、7 经典管道和 7 集成管道)的说明:
http://learn .iis.net/page.aspx/508/wildcard-script-mapping-and-iis-7-integrated-pipeline/
据此,如果是集成管道,则需要添加以下配置参数:
Check this page for instructions on all 3 cases of IIS version (6, 7 Classic pipeline and 7 Integrated pipeline):
http://learn.iis.net/page.aspx/508/wildcard-script-mapping-and-iis-7-integrated-pipeline/
According to it, in case of Integrated pipeline, you need to add the following config parameter:
该应用程序会忽略您的 CSS 文件,因为 IIS 会忽略 CSS 文件。
它未映射到 IIS 中的可执行文件。
替代文本 http://www.fastpics.net/sharepics/imih41904722.jpg
尝试添加 .css 扩展名并将其映射到 .NET dll。
The App ignores your CSS files because IIS ignores CSS files.
It's not mapped to an executable in IIS.
alt text http://www.fastpics.net/sharepics/imih41904722.jpg
Try adding the .css extension and map it to the .NET dll.