在 ASP.NET MVC 应用程序中,简单的自定义 HTTPModule 问题

发布于 2024-08-23 04:35:11 字数 1017 浏览 9 评论 0原文

我的第一个自定义 HTTP 模块,第一步 - 只是搞定管道。

我没有在 200 响应中得到我的字符串,但它在 304 响应中得到。谁能告诉我我错过了什么?

我的班级:

namespace WebUI.Models
{
    public class SimpleModule: IHttpModule
    {
        public void Dispose()
        {
        }

        public void Init(HttpApplication context)
        {
            context.EndRequest += OnEndRequest;
        }        

        void OnEndRequest(object sender, System.EventArgs e)
        {            
            HttpContext.Current.Response.Write("rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr");           
        }
    }
}

这就是我收到的 css 文件请求,最后有我的“rrrrrr....rrrr”:

HTTP/1.1 304 Not Modified

Content-Type: text/html; charset=utf-8

Last-Modified: Sat, 20 Feb 2010 17:20:59 GMT

Accept-Ranges: bytes

ETag: "b0d1d31151b2ca1:0"

Server: Microsoft-IIS/7.0

X-Powered-By: ASP.NET

Date: Thu, 25 Feb 2010 22:57:31 GMT

rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr

但是 r 没有显示在我对页面 html 的 200 响应中。

感谢您的帮助, 账单

My first custom HTTP Module, baby step 1 - just getting the plumbing down.

I'm not getting my string in the 200 response but it is there in 304 responses. Can anyone tell me what I'm missing?

My class:

namespace WebUI.Models
{
    public class SimpleModule: IHttpModule
    {
        public void Dispose()
        {
        }

        public void Init(HttpApplication context)
        {
            context.EndRequest += OnEndRequest;
        }        

        void OnEndRequest(object sender, System.EventArgs e)
        {            
            HttpContext.Current.Response.Write("rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr");           
        }
    }
}

This is what I'm getting for a request for a css file and there's my "rrrrrr....rrrr" at the end:

HTTP/1.1 304 Not Modified

Content-Type: text/html; charset=utf-8

Last-Modified: Sat, 20 Feb 2010 17:20:59 GMT

Accept-Ranges: bytes

ETag: "b0d1d31151b2ca1:0"

Server: Microsoft-IIS/7.0

X-Powered-By: ASP.NET

Date: Thu, 25 Feb 2010 22:57:31 GMT

rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr

But the r's don't show in my 200 response for the page's html.

Thanks for any help,
Bill

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

猫性小仙女 2024-08-30 04:35:12

好的,找到原因了——压缩。我把它拿出来,现在我在 200 回复中收到了 rrrr。现在我只需要弄清楚为什么会这样。

//response.Filter = new GZipStream(response.Filter, compress);

OK, figured out why - Compression. I took it out and now I'm getting the rrrr's in my 200 response. Now I just have to figure out why this is so.

//response.Filter = new GZipStream(response.Filter, compress);

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