为什么我的 HttpHandler 被忽略?

发布于 2024-09-08 01:35:28 字数 501 浏览 3 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

那请放手 2024-09-15 01:35:28

您需要在 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.

掩饰不了的爱 2024-09-15 01:35:28

检查此页面以获取有关所有 3 种 IIS 版本(6、7 经典管道和 7 集成管道)的说明:
http://learn .iis.net/page.aspx/508/wildcard-script-mapping-and-iis-7-integrated-pipeline/

据此,如果是集成管道,则需要添加以下配置参数:

runAllManagedModulesForAllRequests="True"

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:

runAllManagedModulesForAllRequests="True"
殤城〤 2024-09-15 01:35:28

该应用程序会忽略您的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文