此应用程序的当前自定义错误设置阻止远程查看应用程序错误的详细信息(出于安全原因)
The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons)
我使用 VS2013 的 FTP 发布选项在 plesk 中托管了我的 MVC 网站,一切顺利,我的意思是所有必需的文件都已正确复制到 httpdocs[=37 下的目标中=] 虚拟目录。但是当我访问 URL:
时,我现在遇到了以下错误
我已经尝试了很多链接中提到的所有可能的解决方案,但没有找到合适的解决方案!这让我真的很困惑!
我尝试在 this and also checked this question 中应用解决方案,但其中 none 很有用。我的 web.config
文件如下:
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=sometoken" requirePermission="false" />
</configSections>
<appSettings>
<!--<add key="MaintenanceMode" value="false" />-->
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="SessionTimeoutRedirect" value="true" />
<add key="isAjaxHandled" value="false" />
</appSettings>
<system.web>
<customErrors mode="Off" />
<trust level="Full"/>
<compilation targetFramework="4.0" defaultLanguage="c#"/>
<httpRuntime executionTimeout="1048576" maxRequestLength="100000" />
<globalization culture="en-IN" uiCulture="en-IN" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" defaultUrl="~/Admin/Index" timeout="2880" protection="Encryption" slidingExpiration="true" cookieless="AutoDetect" />
</authentication>
<pages controlRenderingCompatibilityVersion="4.0" />
</system.web>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="MCBConnectionString" connectionString="metadata=res://*/Models.EntityDataModel.MCBEntityModel.csdl|res://*/Models.EntityDataModel.MCBEntityModel.ssdl|res://*/Models.EntityDataModel.MCBEntityModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=somesource;Network Library=;Packet Size=4096;Integrated Security=no;User ID=uid;Password=pwd;Encrypt=yes;TrustServerCertificate=True; integrated security=no;connect timeout=120;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
下面是 Plesk 管理面板中的文件结构
还有一点要注意: 如果我从 web.config
中删除 <trust level="Full"/>
标签,我不会得到任何错误,但也不会显示。将显示空白页
我真的很困惑!除了现在访问这个论坛,我别无选择!有没有遇到过这个问题的专家或者我必须在 web.config
?
上配置更多的东西
放置下面的代码
<compilation debug="true" targetFramework="4.0">
而不是
<compilation targetFramework="4.0" defaultLanguage="c#"/>
希望有用
This Link 实际上可以帮助您识别服务器中未显示的任何类型的问题,因此我 [OP] 能够通过以下方式解决我的问题确定问题。
下面是 link 包含的内容:
When using ASP.NET, you may encounter the following error: "Security
Exception" "Exception Details: System.Security.SecurityException:
Security error."
This means a class during runtime is linked against a restricted
class. By default ASP.NET error messages are optimized for
compile-time and run-time errors only. So the real error sources are
not displayed for linked errors. These errors arise for example, if
you try to access registry variables or system variables etc.
Sometimes you can get detailed error messages by placing the following
code in global.asax
file.
<%@ Application %>
<script runat="server" language="c#">
protected void Application_Error(Object sender, EventArgs e){
Exception ex = Server.GetLastError();
Server.ClearError();
Response.Write("<pre>");
Response.Write(Environment.NewLine);
Response.Write("Caught Exception: " + ex.ToString() + Environment.NewLine);
if (ex.InnerException != null){
Response.Write(Environment.NewLine);
Response.Write("Inner Exception: " + ex.InnerException.ToString() + Environment.NewLine);
Response.Write(Environment.NewLine);
}
System.Security.SecurityException ex_security = ex as System.Security.SecurityException;
if (ex_security != null){
Response.Write(Environment.NewLine);
Response.Write("Security Exception Details:");
Response.Write(Environment.NewLine);
Response.Write("===========================");
Response.Write(Environment.NewLine);
Response.Write("PermissionState: " + ex_security.PermissionState + Environment.NewLine);
Response.Write("PermissionType: " + ex_security.PermissionType + Environment.NewLine);
Response.Write("RefusedSet: " + ex_security.RefusedSet + Environment.NewLine);
}
Response.Write("</pre>");
}
</script>
如果您正在使用 asp.net mvc5,它需要完全信任,在我写这篇文章的时候 plesk (host gator) 不支持它。
如果是这种情况,您需要降级到 mvc4 或寻找另一个支持完全信任的托管服务提供商
我使用 VS2013 的 FTP 发布选项在 plesk 中托管了我的 MVC 网站,一切顺利,我的意思是所有必需的文件都已正确复制到 httpdocs[=37 下的目标中=] 虚拟目录。但是当我访问 URL:
时,我现在遇到了以下错误我已经尝试了很多链接中提到的所有可能的解决方案,但没有找到合适的解决方案!这让我真的很困惑!
我尝试在 this and also checked this question 中应用解决方案,但其中 none 很有用。我的 web.config
文件如下:
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=sometoken" requirePermission="false" />
</configSections>
<appSettings>
<!--<add key="MaintenanceMode" value="false" />-->
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="SessionTimeoutRedirect" value="true" />
<add key="isAjaxHandled" value="false" />
</appSettings>
<system.web>
<customErrors mode="Off" />
<trust level="Full"/>
<compilation targetFramework="4.0" defaultLanguage="c#"/>
<httpRuntime executionTimeout="1048576" maxRequestLength="100000" />
<globalization culture="en-IN" uiCulture="en-IN" />
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" defaultUrl="~/Admin/Index" timeout="2880" protection="Encryption" slidingExpiration="true" cookieless="AutoDetect" />
</authentication>
<pages controlRenderingCompatibilityVersion="4.0" />
</system.web>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="MCBConnectionString" connectionString="metadata=res://*/Models.EntityDataModel.MCBEntityModel.csdl|res://*/Models.EntityDataModel.MCBEntityModel.ssdl|res://*/Models.EntityDataModel.MCBEntityModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=somesource;Network Library=;Packet Size=4096;Integrated Security=no;User ID=uid;Password=pwd;Encrypt=yes;TrustServerCertificate=True; integrated security=no;connect timeout=120;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
下面是 Plesk 管理面板中的文件结构
还有一点要注意: 如果我从 web.config
中删除 <trust level="Full"/>
标签,我不会得到任何错误,但也不会显示。将显示空白页
我真的很困惑!除了现在访问这个论坛,我别无选择!有没有遇到过这个问题的专家或者我必须在 web.config
?
放置下面的代码
<compilation debug="true" targetFramework="4.0">
而不是
<compilation targetFramework="4.0" defaultLanguage="c#"/>
希望有用
This Link 实际上可以帮助您识别服务器中未显示的任何类型的问题,因此我 [OP] 能够通过以下方式解决我的问题确定问题。
下面是 link 包含的内容:
When using ASP.NET, you may encounter the following error: "Security Exception" "Exception Details: System.Security.SecurityException: Security error."
This means a class during runtime is linked against a restricted class. By default ASP.NET error messages are optimized for compile-time and run-time errors only. So the real error sources are not displayed for linked errors. These errors arise for example, if you try to access registry variables or system variables etc. Sometimes you can get detailed error messages by placing the following code in
global.asax
file.
<%@ Application %>
<script runat="server" language="c#">
protected void Application_Error(Object sender, EventArgs e){
Exception ex = Server.GetLastError();
Server.ClearError();
Response.Write("<pre>");
Response.Write(Environment.NewLine);
Response.Write("Caught Exception: " + ex.ToString() + Environment.NewLine);
if (ex.InnerException != null){
Response.Write(Environment.NewLine);
Response.Write("Inner Exception: " + ex.InnerException.ToString() + Environment.NewLine);
Response.Write(Environment.NewLine);
}
System.Security.SecurityException ex_security = ex as System.Security.SecurityException;
if (ex_security != null){
Response.Write(Environment.NewLine);
Response.Write("Security Exception Details:");
Response.Write(Environment.NewLine);
Response.Write("===========================");
Response.Write(Environment.NewLine);
Response.Write("PermissionState: " + ex_security.PermissionState + Environment.NewLine);
Response.Write("PermissionType: " + ex_security.PermissionType + Environment.NewLine);
Response.Write("RefusedSet: " + ex_security.RefusedSet + Environment.NewLine);
}
Response.Write("</pre>");
}
</script>
如果您正在使用 asp.net mvc5,它需要完全信任,在我写这篇文章的时候 plesk (host gator) 不支持它。
如果是这种情况,您需要降级到 mvc4 或寻找另一个支持完全信任的托管服务提供商