在 ASP.NET MVC 应用程序中,简单的自定义 HTTPModule 问题
我的第一个自定义 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,找到原因了——压缩。我把它拿出来,现在我在 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);