ASP.Net 集成管道和 HTTPResponseBase.Headers
好的...
我正在编写一个 ASP.Net MVC 2 应用程序,其中一个要求是我记录我们收到的请求以及我们发送的响应的标头...
我的方法是创建一个重写 OnActionExecuting 和 OnActionExecuted 的控制器,然后通过继承此控制器而不是通常的基类来创建我们实际的“实时”控制器。这样,我基本上免费获得了日志记录功能。
虽然这种方法可以很好地处理请求,但响应似乎是另一回事。我收到一条错误消息,告诉我 HTTPResponseBase 类的 Headers 属性要求 IIS 使用集成管道。因此我有两个问题。
问题 1.
任何人都可以建议一种通过 HTTPResponseBase.Headers 以外的方式获取标头的方法吗?例如,我考虑过简单地解析整个响应并自己以这种方式获取它们,但我希望有人可能有更好的方法...
问题 2.
这个集成管道是什么?它有什么作用?我该如何启用它?
欢呼雀跃,期待......
马丁。
Ok...
I'm writing a ASP.Net MVC 2 application, and one of the requirements is that I log the headers on the requests we receive, and also on the responses we send...
My approach to do this has been to create a controller that overrides OnActionExecuting and OnActionExecuted, and then create our actual "live" controllers by inheriting from this rather than from the usual base class. This way, I basically get the logging functionality for free.
While this approach works fine for handling the requests, responses seem to be another matter. I am getting an error telling me that the Headers property of the HTTPResponseBase class requires IIS to be using the Integrated Pipeline. I therefore have two questions.
Question 1.
Can anyone suggest a means to get the headers through a means other than HTTPResponseBase.Headers? I have considered for example simply parsing the entire resposne and getting them that way myself, but I was hoping someone might have a better way...
Question 2.
What is this Integrated Pipeline? What does it do? How do I enable it?
Cheers in anticipation...
Martin.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
针对问题2:
集成管道是IIS 7及更高版本中的新功能,您可以更改IIS7中的应用程序池以使用此新管道。
In response to Question 2:
Integrated Pipeline is a new feature in IIS 7 and higher, you can change the application pool in IIS7 to use this new pipeline.