Error when calling MvcHttpHandler.ExecuteRequest from custom IHttpHandler

删除回忆录丶 提交于 2019-12-21 10:46:28

问题


I have a custom IHttpHandler that calls MvcHttpHandler implemented as described in this answer.

It worked well in asp.net MVC2, but after I migrate the code to MVC4 with IISExpress 7.5, I start getting InvalidOperationException on the line:

httpHandler.ProcessRequest(HttpContext.Current);

with message:

'HttpContext.SetSessionStateBehavior' can only be invoked before 'HttpApplication.AcquireRequestState' event is raised.

ASP.NET Development Server does not make any problems.

Does anyone know what's going on here, and how to solve it?


回答1:


I believe you need to use httpContext.Server.TransferRequest with the MVC update.

See this question: MVC3 Application Inside Webforms Application Routing is throwing a HttpContext.SetSessionStateBehavior Error in IIS7.5



来源:https://stackoverflow.com/questions/10998664/error-when-calling-mvchttphandler-executerequest-from-custom-ihttphandler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!