gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 07:31:46 25 4
gpt4 key购买 nike

我正在 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 配置、在集成模式下运行的应用程序池等。

如有任何帮助,我们将不胜感激。

最佳答案

我们遇到了类似的问题。 MVC2 及更高版本中 MVCHttpHandler 发生了变化。

您需要将其更改为使用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

关于asp.net-mvc-3 - Webforms 应用程序路由内的 MVC3 应用程序在 IIS7.5 中引发 HttpContext.SetSessionStateBehavior 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10639822/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com