更改 Http 方法 +开始请求事件处理程序
我目前正在 ASP .NET MVC 3 项目中编写自定义 HttpModule。 我有关于在此网页上编写自定义 HttpModule 的文档: http://msdn .microsoft.com/en-us/library/ms227673.aspx
在我的模块中,我已开始实现 BeginRequest 事件的处理程序。 在我的处理程序中,我想更改管道中当前处理的请求。 我想更改请求,以便稍后在管道中执行“Connection”控制器的 HttpGet“Index”操作方法。
我知道如何更改 URL,但我需要帮助来设置请求的 Http 方法。 如果客户端使用 POST 或其他方法发送请求,我需要将 HTTP 方法设置为 GET。
预先感谢您未来的帮助
I am currently writing a custom HttpModule in an ASP .NET MVC 3 project.
I have got documentation about writing a custom HttpModule on this web page : http://msdn.microsoft.com/en-us/library/ms227673.aspx
In my module I have started to implement a handler for the BeginRequest event.
In my handler I want to change the request currently processing in the pipeline.
I want to change the request so that the HttpGet "Index" action method of my "Connection" controller will be executed later in the pipeline.
I know how to change the URL but I need help to set the Http method of the request.
I need to set the HTTP method to GET if the request was sent by the client with POST or another method.
Thanks in advance for your future help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在服务器上,您无法更改客户端发送的 HTTP 请求的动词。这根本没有道理。这就像试图让一只死去的动物活下去。一旦使用特定动词发送请求,该动词将在整个请求中使用。
此外,HttpModule 在 ASP.NET MVC 中并不常见。 操作过滤器是在控制器执行中订阅不同事件的首选方式。
On the server you cannot change the verb of an HTTP request that was sent by the client. That simply doesn't make sense. It's like trying to survive a dead animal. Once the request is sent using a particular verb, this verb will be used throughout the entire request.
Also HttpModules are not common in ASP.NET MVC. Action filters are the preferred way to subscribe to different events in the execution of controllers.