简体   繁体   English

使用 Visual Studio 2019 的 ASP.NET 中的 C# 配置错误

[英]C# configuration error in ASP.NET using Visual Studio 2019

I am trying to run the program which is an ASP.Net C# program.我正在尝试运行作为 ASP.Net C# 程序的程序。

However I get this error:但是我收到此错误:

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.但是,它可以被本地服务器机器上运行的浏览器查看。

I have checked the web.config file Line 37 which looks okay.我检查了web.config文件第 37 行,看起来没问题。

Can anyone please guide me on what the issue is谁能指导我解决问题

<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"/>
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb"
          type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=2.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
          warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>

To enable/disable seeing custom errors on your localhost and remote clients, you need to set the following key in web.config in your case:要启用/禁用在本地主机和远程客户端上查看自定义错误,您需要在web.config中设置以下键:

<customErrors mode="Off">

Will show the detailed ASP.NET errors to the remote clients and to the local host.将向远程客户端和本地主机显示详细的 ASP.NET 错误。

You can read more about this element here您可以在此处阅读有关此元素的更多信息

Also, depending on the .net version you could use this to catch errors (in Global.asax.cs file):此外,根据 .net 版本,您可以使用它来捕获错误(在 Global.asax.cs 文件中):

protected void Application_Error(object sender, EventArgs e)
        {
            try
            {
                Exception ex = new Exception();
                ex = Server.GetLastError();
                if (ex.Message.Contains("NoCatch") || ex.Message.Contains("maxUrlLength"))
                {
                    //log message code here
                    return;
                }
            }
            catch (Exception)
            {
                
            }
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Visual Studio 2019 社区中将 Azure API 链接到 C# ASP.Net 项目的问题 - Issue linking Azure API to C# ASP.Net project in Visual Studio 2019 Community 在Windows上使用Compass与Visual Studio C#和ASP.NET - Using Compass on Windows with Visual Studio C# and ASP.NET 在 Visual Studio 2019 的系统配置中找不到数据提供程序“Mysql.Data.MySqlClient” ASP.net - The data provider 'Mysql.Data.MySqlClient' could not be found in the system configuration on Visual Studio 2019 ASP.net 使用 Visual Studio 2019 C# 的 gRPC 构建错误 - gRPC build error using Visual Studio 2019 C# 在Visual Studio中使用C#将Delphi.NET(ASP.NET 1.1)项目移植到ASP.NET 3.5 - Port Delphi.NET (ASP.NET 1.1) Project to ASP.NET 3.5 using C# in Visual Studio 存储过程(Visual Studio ASP.Net 2005 C#) - stored procedure (Visual Studio ASP.Net 2005 C#) Visual Studio asp.net 2005中的CheckBox控件C# - CheckBox Control in Visual studio asp.net 2005 C# GridView控件(Visual Studio ASP.Net 2008 C#) - GridView Control (Visual Studio ASP.Net 2008 C#) Microsoft 身份平台 Asp.Net c# 和 Visual Studio - Microsoft identity platform Asp.Net c# and Visual Studio 带有ASP.NET MVC,C#,Visual Studio的日历 - Calendar with ASP.NET MVC, C#, Visual Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM