我们的项目在Global.asax的Application_Error里进行异常的全局统一处理,出现异常则记录日志并返回提示的Json,现在本地调试没问题,发布到服务器的IIS上在服务器访问没问题,可是如果在另一台机访问服务器的站点,如果报出异常则直接返回500,换了一台服务器依然如此。请问这排查该如何下手?

解决方案 »

  1.   

    尝试使用Firefox浏览器的firebug来看看。
      

  2.   

    连接:http://www.cnblogs.com/insus/p/3418942.html
      

  3.   

    已经用chrome看了,response就是500状态。
      

  4.   

    在服务器的事件查看器中看看有没有iis错误日志,500应该也会有错误日志
      

  5.   

    也看过事件查看器,没有IIS的错误日志……
      

  6.   


    通过记录日志发现,直到抛出异常上一步依然正常,但没有进入到application_error进行处理,站点用的是state_server,session服务也一切正常
      

  7.   

    好东西,问题是……返回结果是<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <meta name="viewport" content="width=device-width" />
        <title>错误</title>
    </head>
    <body>
        <hgroup>
            <h1>错误。</h1>
            <h2>处理你的请求时出错。</h2>
        </hgroup>
    </body>
    </html>
      

  8.   

    发布到服务器的IIS上在服务器访问没问题,可是如果在另一台机访问服务器的站点,如果报出异常则直接返回500我建议楼主去防火墙把iis上站点的端口加进去。
    控制面板--防火墙--入站规则--新建规则--选择端口填写完后在试试。
      

  9.   

    或者我的描述不详细,我们的项目是前后端分离,之间只通过JSON交互,如果没有异常的话那么一切正常,请求返回的都是200,但只要一出现异常请求则变成500,根据日志记录发现是没进入到application_error.
      

  10.   

    另外telnet的话端口正常
      

  11.   

    更新调试结果:在Application_Start里添加日志记录,发现是有的,也就是不存在Global.asax加载失败问题
      

  12.   

    首先要找出来这个500是谁抛出来的。不一定是最终的IIS跑出来的。
      

  13.   

    发布到本地然后附加进程调试完全没问题,但别的机子发送请求来调试发现只能跑到抛出异常那一句,application_error连进都没进。
      

  14.   

    1.看看IIS上的FrameWork版本是否和开发中的版本一致.
    2.看看是否放在根目录上,我有一次也是报错,弄了很久,发现放在根目录就行了,也不知道为什么.
      

  15.   

    谢谢大家回帖,问题已经解决了,stackoverflow果然是吾等码农的苦海明灯……
    http://stackoverflow.com/questions/6508415/application-error-not-firing-when-customerrors-on
    重要的是下面这段:
    By default (when a new project is generated), an MVC application has some logic in the Global.asax.cs file. This logic is used for mapping routes and registering filters. By default, it only registers one filter: a HandleErrorAttribute filter. When customErrors are on (or through remote requests when it is set to RemoteOnly), the HandleErrorAttribute tells MVC to look for an Error view and it never calls the Application_Error() method. I couldn't find documentation of this but it is explained in this answer on programmers.stackexchange.com.
    所以将Application_Start中的这一句注释掉就行
    //FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);