我正在Web表单应用程序的子文件夹中运行混合MVC应用程序.
在VS 2010调试(Cassini)中,一切都运行良好,但是当我部署到IIS7.5时
我收到以下错误:
'HttpContext.SetSessionStateBehavior' can only be invoked before 'HttpApplication.AcquireRequestState' event is raised.
它在MVC应用程序子文件夹的default.aspx文件中的最后一行(httpHandler.ProcessRequest(HttpContext.Current);)上出错.
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); }
但是,如果我从MVC根文件夹手动导航到Home / Index,我可以从那里看到我的应用程序正常.
我查找了抛出的错误,我只找到处理服务器传输而不是MVC路由的答案.
我还检查了路由处理模块的IIS7.5配置,以集成模式运行的应用程序池等.
任何帮助,将不胜感激.