gpt4 book ai didi

asp.net-mvc-3 - 执行子请求时出错

转载 作者:行者123 更新时间:2023-12-01 12:49:50 28 4
gpt4 key购买 nike

在我的 MVC3 应用程序中,当我尝试处理超出最大请求的错误时出现上述错误。

我在应用程序级别处理异常。我正在尝试重定向到位于 View 的共享文件夹中的错误页面。

如果请求大小超过限制,我将使用下面的代码重定向到错误页面。

 this.Server.ClearError();
this.Server.Transfer("~/Views/Shared/NotAuthorised.cshtml");

这是我收到的错误。

Error executing child request for /SiteName/Views/Shared/NotAuthorised.cshtml

最佳答案

根据 Microsoft 文档 (Error Executing Child Request" Error Message When You Use Server.Transfer or Server.Execute in ASP.NET Page),您不能在应用程序级错误后使用 Server.Transfer

Microsoft Internet Information Services (IIS) dispatches the Server.Transfer or the Server.Execute request to the appropriate Internet Server Application Programming Interface (ISAPI) extension based on the extension of the requesting file. For example, a request for an .aspx page is dispatched to the Aspnet_isapi.dll ISAPI extension.

After the request is dispatched to appropriate ISAPI extension, the ISAPI extension cannot call another ISAPI extension. You receive the error message that is listed in the "Symptoms" section because the Aspnet_isapi.dll file, which handles requests to ASP.NET pages, cannot forward the request to the Asp.dll file, which handles requests to ASP pages.

但是您可以像这样使用 Response.Redirect(path):

Response.Redirect("Home/About");

关于asp.net-mvc-3 - 执行子请求时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13343960/

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