문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top