标签: custom-error-pages

ELMAH - 使用自定义错误页面收集用户反馈

我正在寻找第一次使用ELMAH,但是需要满足我不确定如何实现的要求......

基本上,我将配置ELMAH在asp.net MVC下工作,并让它在发生错误时将错误记录到数据库中.除此之外,我将使用customErrors在发生错误时将用户定向到友好的消息页面.相当标准的东西......

要求是在这个自定义错误页面上我有一个表单,使用户可以根据需要提供额外的信息.现在问题出现的原因是此时已经记录了错误,我需要将漏洞错误与用户反馈相关联.

通常,如果我使用自己的自定义实现,在记录错误后,我会将错误的ID传递给自定义错误页面,以便可以建立关联.但由于ELMAH的工作方式,我不认为这是可能的.

因此我想知道人们怎么会想到这样做......

干杯

更新:

我对这个问题的解决方案如下:

public class UserCurrentConextUsingWebContext : IUserCurrentConext
{
    private const string _StoredExceptionName = "System.StoredException.";
    private const string _StoredExceptionIdName = "System.StoredExceptionId.";

    public virtual string UniqueAddress
    {
        get { return HttpContext.Current.Request.UserHostAddress; }
    }

    public Exception StoredException
    {
        get { return HttpContext.Current.Application[_StoredExceptionName + this.UniqueAddress] as Exception; }
        set { HttpContext.Current.Application[_StoredExceptionName + this.UniqueAddress] = value; }
    }

    public string StoredExceptionId
    {
        get { return HttpContext.Current.Application[_StoredExceptionIdName + this.UniqueAddress] as string; }
        set { HttpContext.Current.Application[_StoredExceptionIdName + this.UniqueAddress] = value; …
Run Code Online (Sandbox Code Playgroud)

error-handling asp.net-mvc elmah custom-error-pages

8
推荐指数
1
解决办法
3239
查看次数

使用nginx返回自定义403错误页面

我试图在发生403错误时在/temp/www/error403.html中显示错误页面.

这应该是每当用户尝试通过https(ssl)访问该站点并且它的IP位于blovkips.conf文件中时,但此时它仍然显示nginx的默认错误页面.我有其他服务器相同的代码(没有任何阻止),它的工作原理.

是否阻止IP访问自定义403页面?如果是这样,我如何让它工作?

server  {
    # ssl
    listen               443;
    ssl                  on;
    ssl_certificate      /etc/nginx/ssl/site.in.crt;
    ssl_certificate_key  /etc/nginx/ssl/site.in.key;
    keepalive_timeout    70;

    server_name localhost;


    location / {
            root   /temp/www;
            index  index.html index.htm;
}

# redirect server error pages to the static page
error_page   403  /error403.html;
# location = /error403.html {
#         root   /temp/www;
# }

    # add trailing slash if missing
    if (-f $document_root/$host$uri) {
            rewrite ^(.*[^/])$ $1/ permanent;
    }      

    # list of IPs to block
    include blockips.conf;
}
Run Code Online (Sandbox Code Playgroud)

编辑: 更正了错误页面代码从504到403,但我仍然有同样的问题

webserver nginx custom-error-pages http-status-code-403

8
推荐指数
1
解决办法
3万
查看次数

Internet Explorer中不显示自定义HTTP错误页面

我正在使用Tomcat 7和JSP页面.我想为HTTP 500错误提供自定义错误页面.

我所做的是声明自定义错误页面如下web.xml:

<error-page>
  <error-code>500</error-code>
  <location>/error.jsp</location>
</error-page>
Run Code Online (Sandbox Code Playgroud)

我创建了一个error.jsp使用以下代码调用的JSP :

<%@ page pageEncoding="UTF-8" isErrorPage="true" %>
<!DOCTYPE html>
<html>
  <head>
    <title>500</title>
  </head>
  <body>
    <img src="${pageContext.request.contextPath}/images/500.jpg" />
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

现在这适用于大多数浏览器,但在Internet Explorer中我被带到标准"网站无法显示页面"页面.

为什么我的自定义HTTP 500错误页面未在Internet Explorer中显示?

internet-explorer jsp custom-error-pages

8
推荐指数
1
解决办法
8493
查看次数

添加默认路径时,HttpError iis config抛出异常

我有这个配置工作,并正确重定向以下错误

<httpErrors errorMode="Custom" 
        existingResponse="Replace" 
        defaultResponseMode="ExecuteURL" >
  <remove statusCode="403" />
  <remove statusCode="404" />
  <remove statusCode="500" />
  <error statusCode="403" responseMode="ExecuteURL" path="/Error/AccessDenied" />
  <error statusCode="404" responseMode="ExecuteURL" path="/Error/PageNotFound" />
  <error statusCode="500" responseMode="ExecuteURL" path="/Error/ApplicationError" />
</httpErrors>
Run Code Online (Sandbox Code Playgroud)

但是当我添加以下默认路径以尝试添加catch all时

<httpErrors errorMode="Custom" 
        existingResponse="Replace" 
        defaultResponseMode="ExecuteURL" 
        defaultPath="/Error/ApplicationError">
Run Code Online (Sandbox Code Playgroud)

服务器抛出web.config错误

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Module     CustomErrorModule
Run Code Online (Sandbox Code Playgroud)

现在,这与msdn上文档直接相矛盾

任何帮助将不胜感激!!

asp.net iis-7 web-config custom-error-pages

8
推荐指数
3
解决办法
3973
查看次数

ASP.NET MVC应用程序的自定义401错误页面

我创建了一个使用集成Windows身份验证的ASP.NET MVC应用程序.实施了以下授权逻辑:

  1. 尝试通过NTLM从活动目录获取帐户凭据.

    • 如果收到凭据且Windows帐户具有所需权限,则执行请求的操作.
    • 否则请转至第2条.
  2. 显示Windows身份验证对话框,以便用户可以提供其他凭据: 身份验证对话框

    • 如果收到其他凭据且用户具有所需权限,则执行请求的操作.
    • 如果未收到其他凭据或帐户权限少于其要求,则重复第2条.
    • 如果取消验证对话框,则显示401错误消息.

然后我使用VictorySaber的解决方案为应用程序添加了自定义错误页面:

protected void Application_EndRequest()
{
    int status = Response.StatusCode;
    string actionName;
    if (status >= 400 && status < 500)
    {
        switch (status)
        {
            case 401:
                actionName = "Unauthorized";
                break;

            // Handle another client errors

            default:
                actionName = "BadRequest";
                break;
            }
        }
    else if (status >= 500 && status < 600)
    {
        switch (status)
        {
            case 501:
                actionName  = "NotImplemented";
                break;

            // Handle another server errors

            default:
                actionName  = "InternalServerError"; …
Run Code Online (Sandbox Code Playgroud)

c# windows-authentication custom-error-pages asp.net-mvc-5

8
推荐指数
1
解决办法
1451
查看次数

IIS中为代码400(错误请求)配置的自定义错误页面将被忽略

对于我的网站,我配置了一些自定义错误页面 如果我生成404,重定向工作正常.点击400时,显示"错误请求"文本而不是配置的URl.

作为测试,我将URL从404复制到400.没有变化.然后我将重定向更改为文件.没变.

有任何想法吗?

asp.net iis asp.net-mvc custom-error-pages

7
推荐指数
2
解决办法
9202
查看次数

空页而不是自定义tomcat错误页面

我的设置:Apache 2.2 + Tomcat 6.0 @ Windows 2008 R2 64bit

  • 静态网页:/
  • servlet:/ foo
  • tomcat和apache由mod_jk连接
  • 404.jsp放在tomcat\webapps\ROOT中

tomcat的\的conf\web.xml文件:

<error-page>
 <error-code>404</error-code>
 <location>/404.jsp</location>
</error-page>
Run Code Online (Sandbox Code Playgroud)

阿帕奇\的conf \额外\的httpd-ssl.conf中:

JkMount /foo/* worker1
JkMount /404.jsp worker1
Run Code Online (Sandbox Code Playgroud)

当我打开https://...../404.jsp时,会显示我的自定义错误页面.但是当我打开https://...../foo/nonexisting.html时,会显示一个空白页面.

如果我<error-page>...</error-page>从web.xml中删除代码并打开https://...../foo/nonexisting.html,则显示tomcats自己的404.

任何提示?

tomcat custom-error-pages

7
推荐指数
1
解决办法
1万
查看次数

经典ASP:捕获错误

是否有可能在全球范围内捕获Classic ASP中的所有500个错误?也许是IIS中的东西.我现在正在使用II6.我喜欢捕获错误消息,然后将其存储在数据库中.我知道它可能在ASPX页面中,但不知道你在经典asp中的确切方式.

谢谢

custom-error-pages asp-classic

7
推荐指数
3
解决办法
1万
查看次数

Symfony2:自定义错误页面扩展base.html.twig

我试图在Symfony中自定义错误页面.

这是我的error.html.twig文件位于app/Resources/TwigBundle/views/Exception/:

{% extends '::base.html.twig' %}

{% block body %}

<h1>{{ status_code }}: {{ status_text }}</h1>

{% endblock %}
Run Code Online (Sandbox Code Playgroud)

不幸的是我收到以下错误消息:

致命错误:第144行上的供应商\ symfony\symfony\src\Symfony\Component\HttpKernel\EventListener\RouterListener.php中未捕获的异常'Symfony\Component\Routing\Exception\ResourceNotFoundException'

当我删除{% extends '::base.html.twig' %}一切工作正常.有关如何将我的基本模板包含在错误页面中的任何想法?

编辑1: 奇怪的是它似乎在抛出403时工作,例如,当我访问/user但没有必要的权限时.

编辑2: 我将我的整个内容粘贴base.html.twigerror.html.twig文件中,并注意到错误是由于KnpMenuBundle捆绑包呈现的菜单引起的:

{{ knp_menu_render('ACMEMemberBundle:Builder:mainMenu', { 'style': 'pills', 'currentClass': 'active' }) }}
Run Code Online (Sandbox Code Playgroud)

当我删除这一行时,一切正常.但这不是我想要的方式.导航没有可能吗?

custom-error-pages symfony

7
推荐指数
1
解决办法
2121
查看次数

使用CustomErrors删除aspxerrorpath param使用ResponseRewrite

我正在使用asp.net MVC4 + visual studio 2012.一切都很好,但只有自定义错误总是在URL上有aspxerrorpath参数.

我已经在web.config上配置了自定义错误:

<customErrors mode="On" defaultRedirect="~/Error/Error">
  <error redirect="~/Error/Error" statusCode="404" />
  <error redirect="~/Error/Error" statusCode="500" />
</customErrors>
Run Code Online (Sandbox Code Playgroud)

我还将错误操作更改为:

public ActionResult Error()
{
    Response.Status = "404 Not Found";
    Response.StatusCode = 404;
    return View();
}
Run Code Online (Sandbox Code Playgroud)

现在会发生404事件.我的URL上总是有aspxerrorpath param. 我尝试添加redirectMode="ResponseRewrite"到customError节点但是如果添加这个,错误将显示运行时异常.....

那么有没有最好的方法来删除aspxerrorpath param?谢谢.

custom-error-pages asp.net-mvc-4

7
推荐指数
2
解决办法
8407
查看次数