我正在Web表单应用程序的子文件夹中运行混合MVC应用程序.
在VS 2010调试(Cassini)中,一切都运行良好,但是当我部署到IIS7.5时
我收到以下错误:
'HttpContext.SetSessionStateBehavior' can only be invoked before
'HttpApplication.AcquireRequestState' event is raised.
Run Code Online (Sandbox Code Playgroud)
它在MVC应用程序子文件夹httpHandler.ProcessRequest(HttpContext.Current);的default.aspx文件中的最后一行()上出错.
public void Page_Load(object sender, System.EventArgs e)
{
string pathToRewriteTo = Request.Path.ToLowerInvariant().Replace("default.aspx", "Home/Index");
HttpContext.Current.RewritePath(pathToRewriteTo, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我从MVC根文件夹手动导航到Home/Index,我可以从那里看到我的应用程序正常.
我查找了抛出的错误,我只找到处理服务器传输而不是MVC路由的答案.
我还检查IIS7.5了路由处理模块的配置,以集成模式运行的应用程序池等.
任何帮助,将不胜感激.