我如何获取我的web.config文件以远程显示错误?

问题描述 投票:11回答:2

我试图查看我的网站的错误,当我转到该网站时,我收到此消息:

Server Error in '/' Application.

Runtime Error

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. 

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".


<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.


<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>

所以我要做的就是创建一个包含以下内容的web.config文件:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
     <customErrors mode="Off"/>
  </system.web>
</configuration>

但是对我来说可悲的是,杰克真的与众不同。伙计们,我在做什么错?

asp.net web-config
2个回答
8
投票

尝试一下:CustomErrors mode="Off"

顺便说一下,asp net项目模板包含web.config文件(它应该在项目的根文件夹中),因此您不必手动创建它。可能您已经创建了另一个?


0
投票

如果您在本地而不是远程看到错误,请尝试将其添加到web.config;

<system.webServer>
    <httpErrors errorMode="Detailed" />
</system.webServer>

这是IIS的一项功能,可将外部网站潜在的潜在危害隐藏给外部用户,因此有理由不将其默认为det。

© www.soinside.com 2019 - 2024. All rights reserved.