- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我目前有 httpErrors
在此处设置以处理 500:-
<httpErrors errorMode="Custom" existingResponse="Replace">
......
<remove statusCode="500"/>
<error statusCode="500" path="/server-error" responseMode="ExecuteURL"/>
</httpErrors>
这工作正常,但在 iis 收到错误的情况下,我仍然会看到蓝屏死机。一个例子是 Entity Framework 无法连接到数据库并且我收到:-
Cannot open database "Test-DB" requested by the login.
The login failed.
Login failed for user 'sa'.
我已经设置了 customErrors
处理这个:-
<customErrors mode="On" defaultRedirect="error.html" redirectMode="ResponseRedirect">
<error statusCode="500" redirect="error.html" />
</customErrors>
只要没有 modules
就可以正常工作没有preCondition="managedHandler"
.
我有几个处理图像和 css 文件的模块,它们在同一个项目中。
<modules runAllManagedModulesForAllRequests="false">
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
<add name="ImageHandler" type="foo.bar.ProductImageHandlerHttpModule" />
<add name="CustomCssHandler" type="foo.bar.CustomCssHttpModule" />
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" preCondition="integratedMode" />
</modules>
将这些注释掉,我得到 error.html
, 把它们放在里面,我得到
Runtime Error
Description: An exception occurred while processing your request. Additionally, another exception occurred while executing the custom error page for the first exception. The request has been terminated.
显示项目中的模块在尝试显示 error.html
时也出错.
有人知道修复/解决方法吗?
最佳答案
这是一个棘手的情况 - 您的错误来自 HttpModule
,它针对每个请求运行 - 包括对 error.html
页面的请求。一种方法是仅通过您的服务器路由静态文件(例如 error.html)——并在 .NET 级别忽略它们;这可能并不总是可行的(有时在 .NET 级别处理静态文件很方便)。我能想到的唯一其他方法是在 global.asax 中 Hook 到错误事件并自己处理它(这将忽略 customErrors
)
类似于:
public class Global : System.Web.HttpApplication
{
protected void Application_Error(object sender, EventArgs e)
{
// is there an error ?
var error = Server.GetLastError();
if (error != null)
{
// mark the error as - "i'll handle it myself"
Server.ClearError();
// load error.html manually & dump it to response
var content = File.ReadAllText(Server.MapPath("~/error.html"));
Context.Response.Write(content);
// set correct error code
Context.Response.StatusCode = 500;
}
}
}
注意:这个是可以解决的,但是你看大体原理...
关于c# - customErrors 与自定义模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40151520/
本篇参考: https://help.salesforce.com/s/articleView?id=sf.flow_ref_elements_custom_error.htm&ty
我想使用 catchError 将我的错误返回为自定义类型。起初,我希望我的网络层返回 Observable,然后在 ViewModel 中我为它订阅了 .OnNext、.OnError、.OnCom
我目前有 httpErrors在此处设置以处理 500:- ...... 这工作正常,但在 iis 收到错误的情况下,我仍然会看到蓝屏死机。一个
是否可以在 Web 应用程序运行时的代码中检查天气自定义错误是打开还是关闭。 最佳答案 我已经想出了如何去做它在... HttpContext.Current.IsCustomErrorEnabled
我已经将我的网页上传到服务器。 我的网页在本地系统中运行良好。但是当我将它上传到服务器时却显示错误 The configuration section 'customErrors' cannot be
当我尝试使用远程处理连接到我的服务器应用程序时出现以下错误: A problem seems to have occured whilst connecting to the remote serve
在我的 ASP.NET 网站的 web.config 中,我有 customErrors在 HTTP 404 的情况下,打开并设置为重定向到特定操作: 现在我启动 Fiddler 并在我的浏览器中查询
我创建了一个 asp.net 网页并将其上传到网络服务器上。但是,当我尝试远程查看页面时,我收到有关 web.config 文件中 customerror 标记的错误。该页面在本地工作,没有错误或警告
我有asp.net mvc 3应用程序。 当用户传递不存在的对象的ID时,我以这种方式返回404 View : Response.StatusCode = 404; return View("404"
我有一台机器上的 8080 端口上运行的 ASP.NET 服务器,出于性能原因,一个 nginx 缓存反向代理在端口 80 上运行。请求会发送到端口 80,然后,如果 nginx 缓存没有响应,则将其
这是做什么用的? ASP.NET 错误提示我必须将其放入我的 web.config 文件中。这些代码行是做什么的? 最佳答案 您可以阅读有关 的信息元素 here on MSDN .
为什么我的 typescript 引用我的自定义错误给我错误 Argument of type CustomError is not assignable to parameter of type E
来自 msdn站点,我知道 customErrors 元素提供有关 ASP.NET 应用程序的自定义错误消息的信息。 mode 属性的 RemoteOnly 值指定自定义错误仅显示给远程客户端,而 A
在旧站点中,我通过添加 redirectMode="ResponseRewrite" 来更改 CustomErrors 的工作方式(3.5 SP1 中的新增功能): 问题是:它向我显示了
ASP.NET MVC 应用程序中 web.config 文件的 customErrors 和 httpErrors 部分有什么区别? 每个部分的使用指南是什么? 最佳答案 *2016 年 4 月更新
我有这样的 web.config 设置 以及httperrors
正如我们所知,例如What is the difference between customErrors and httpErrors? , CustomErrors是在 Web 应用程序中定义错误页
我只想做如下事情: var defaultRedirectUrl = SomeMethodToGetDefaultRedirect(); 当然在 web.config 中我有 如何做到这一点? 最佳
摘要 customErrors也经常在开发部署中看到<customErrors mode="Off" />,设置这样可以在页面上看到详细的错误信息。但也为黑客提供了
我更改了以下 web.config: 1- VirtualDirectory\80\web.config 2- 14\TEMPLATE\LAYOUTS\web.config 3- 14\TEMPLAT
我是一名优秀的程序员,十分优秀!