[英]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=\"Web\" /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 错误。
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.