【发布时间】:2015-09-09 23:39:59
【问题描述】:
我在主机上部署了我的 ASP.NET 项目,但失败了。我试图解决这个问题几个小时,但不能。 在我的第一页上,用户在单击登录按钮后输入电子邮件和密码,他们导航菜单。所有数据都存储在 mysql 数据库中。发布后我在 bin 文件夹中看不到 mysqldata.dll,所以我手动添加了。
请帮我解决这个问题。我应该在 2 天内部署。
在我尝试登录后显示此问题。
Server Error in '/' Application.
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Source Error:
[No relevant source lines]
Source File: App_Web_0twfxhxf.8.cs Line: 0
Stack Trace:
[SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
MySql.Data.MySqlClient.MySqlConnection.AssertPermissions() +0
MySql.Data.MySqlClient.MySqlConnection.Open() +190
gop.Default.loginbutton_Click(Object sender, EventArgs e) +216
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9628722
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6704
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +245
System.Web.UI.Page.ProcessRequest() +72
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +58
ASP.default_aspx.ProcessRequest(HttpContext context) in App_Web_0twfxhxf.8.cs:0
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
这是 web.config 文件;
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
<add key="webpages:Version" value="2.0.0.0"/>
</appSettings>
<connectionStrings>
<add name="MySqlConnectionString" connectionString="Server=xxx;Database=xxx;Uid=xxx;Pwd=xxx;charset=utf8;Integrated Security=false"
providerName="MySql.Data.MySqlClient" />
</connectionStrings>
<system.web>
<customErrors mode="Off" />
<compilation targetFramework="4.0" debug="true"/>
<httpRuntime targetFramework="4.0" />
</system.web>
</configuration>
我尝试在 web.config 文件中添加<trust level="Medium" />,但之后连第一页都无法显示并出现问题。
Server Error in '/' Application.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: This configuration section cannot be used at this path. This happens when the site administrator has locked access to this section using <location allowOverride="false"> from an inherited configuration file.
Source 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.
Source File: D:\inetpub\xxx.com\www\web.config Line: 24
【问题讨论】:
-
您的托管公司是否声称支持 MySql?问题是他们设置了他们的信任级别,因此安全性无法尝试打开连接。您可能需要联系他们的支持以寻找工作示例或切换到支持 MySql 的主机。
-
是的,他们支持 MySql 并且他们的信任级别是中等的。我是 c# 和 asp.net 的新手,所以我的 web.config 文件是真的吗?有什么错误吗?
-
您是否尝试设置
?当您已经处于中等信任状态时,通常会发生这种错误。 -
是的,我试过但没用。
-
@Onur,您需要检查您的 IIS 上的主站点,也许您的网站位于信任级别低的根网站内。 help.webcontrolcenter.com/kb/a1110/…
标签: c# mysql asp.net security mysql-error-1064