Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 3 Webforms应用程序路由中的MVC3应用程序在IIS7.5中引发HttpContext.SetSessionStateBehavior错误_Asp.net Mvc 3_Iis 7.5_Webforms - Fatal编程技术网

Asp.net mvc 3 Webforms应用程序路由中的MVC3应用程序在IIS7.5中引发HttpContext.SetSessionStateBehavior错误

Asp.net mvc 3 Webforms应用程序路由中的MVC3应用程序在IIS7.5中引发HttpContext.SetSessionStateBehavior错误,asp.net-mvc-3,iis-7.5,webforms,Asp.net Mvc 3,Iis 7.5,Webforms,我正在web表单应用程序的子文件夹中运行一个混合MVC应用程序 在VS2010调试(Cassini)中一切都很好,但当我部署到IIS7.5时 我得到了以下错误: 'HttpContext.SetSessionStateBehavior' can only be invoked before 'HttpApplication.AcquireRequestState' event is raised. 它在MVC应用程序子文件夹的default.aspx文件的最后一行(httpHandler.

我正在web表单应用程序的子文件夹中运行一个混合MVC应用程序

在VS2010调试(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
配置,以及在集成模式下运行的应用程序池等


任何帮助都将不胜感激。

我们面临类似的问题。MVC2及以上版本中对MVCHTTPDhandler进行了更改

您需要将其更改为使用
httpContext.Server.TransferRequest

请尝试以下代码段:

var httpContext = HttpContext.Current;
httpContext.Server.TransferRequest(Url, true); // change to false to pass query string parameters if you have already processed them