关于 <customErrors> 标记的“mode”属性设置为“Off”的问题的解决方案

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> 

 

----------------------------------------------------------解决方案-------------------------------------------------------------------------------------

今天往服务器上部署网站的时候,出现了这个问题。在网上找个很多方法,其实解决起来也灰常简单。如下:

改动前:

 

改动后:

在<system.web>标签中间 添加 "<customErrors mode="Off"/>"(注意大小写,大写O,小写f)即可。

保存之后,再运行,就会报另一个错误了。。。(捂脸)

<?xml version="1.0" encoding="utf-8"?> <!-- 有关如何配置 ASP.NET 应用程序的详细信息,请访问 https://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <connectionStrings> <add name="DB-NetShopsConnectionString" connectionString="Data Source=.\MSSQLSERVER2012;Initial Catalog=DB-NetShops;User ID=sa;Password=your_password;Integrated Security=False" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <!-- 添加全局cookie设置 --> <httpCookies httpOnlyCookies="true" /> <compilation debug="true" targetFramework="4.7.2" /> <httpRuntime targetFramework="4.7.2" maxRequestLength="20480" executionTimeout="300" requestValidationMode="4.7.2" /> <!-- 移除httpOnlyCookies属性 --> <sessionState mode="InProc" timeout="20" /> <authentication mode="Forms"> <!-- 移除httpOnlyCookies属性 --> <forms loginUrl="~/WebForm1.aspx" defaultUrl="~/WebForm2.aspx" timeout="20" /> </authentication> <globalization culture="zh-CN" uiCulture="zh-CN" requestEncoding="utf-8" responseEncoding="utf-8" /> <customErrors mode="RemoteOnly" defaultRedirect="~/Error.aspx"> <error statusCode="404" redirect="~/404.aspx" /> <error statusCode="500" redirect="~/500.aspx" /> </customErrors> </system.web> <system.webServer> <httpProtocol> <customHeaders> <add name="X-Content-Type-Options" value="nosniff" /> <add name="X-Frame-Options" value="SAMEORIGIN" /> <add name="X-Xss-Protection" value="1; mode=block" /> </customHeaders> </httpProtocol> <staticContent> <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" /> </staticContent> <security> <requestFiltering> <requestLimits maxAllowedContentLength="20971520" /> </requestFiltering> </security> </system.webServer> <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" /> </compilers> </system.codedom> </configuration> 仅为这段代码添加母版页代码,并给出完整代码,不要增加或修改无关部分
最新发布
06-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值