【发布时间】:2018-06-26 06:42:49
【问题描述】:
我有一个在 SQL Server 中存储会话的 ASP.NET 网站。我特意让我的会话数据库离线,以确保我的错误页面能够显示给用户。
我的 Web.config :
<system.webServer>
<httpErrors errorMode="DetailedLocalOnly" existingResponse="Replace">
<remove statusCode="404" subStatusCode="13" />
<error statusCode="404" subStatusCode="13" prefixLanguageFilePath="" path="LargeFileError.aspx" responseMode="Redirect" />
<remove statusCode="500" />
<error statusCode="500" path="Error.aspx" responseMode="ExecuteURL"/>
</httpErrors>
</system.webServer>
<system.web>
<customErrors mode="On" defaultRedirect="/Error.aspx" redirectMode="ResponseRewrite">
<error statusCode="500" redirect="Error.aspx" />
</customErrors>
</system.web>
我的 global.asax:
protected void Application_Error(object sender, EventArgs e)
{
Exception exception = Server.GetLastError();
Response.Clear();
Server.ClearError();
Response.Redirect("Error.aspx");
}
我的 Error.aspx 页面是一个简单的页面,它只有一个本地化字符串。因此,将无法使其成为 html 页面。
我不断收到此错误:
“底层提供程序在打开时失败。”
你可能会说这个错误有很多关于堆栈溢出的解决方案,但我这里的问题是显示错误页面(会话数据库关闭时的 aspx 页面)而不是解决这个错误。
即使我直接导航到 error.aspx 页面,我也会收到此错误。 我需要一种方法来告诉 Asp.Net & IIS 我不需要此特定页面的会话信息。
如何解决这个问题并确保显示我的错误页面。
【问题讨论】: