安全异常 ASP.NET/MySQL

Security Exception ASP.NET/MySQL

我在使用 C#

中的 连接字符串 时遇到问题

数据库通过 phpmyadmin 在服务器上(我不拥有在线服务器)

通过 GoDaddy 和 GlobeHost 获得托管,但都遇到同样的问题

我当前的连接设置是 string strcon = "Server=ipAddress(OfServer);Database=testing;Uid=myusername;Pwd=mypassword";

我在 Connection.Open();

时收到此错误

勾选 link testing page

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=**************' failed.

您的虚拟主机已将服务器配置为阻止出站连接,至少是针对您的网站以及可能的端口号。

与您的网络托管服务商联系,了解是否可以授予您权限或其他端口是否已解锁(虽然这是代码访问安全配置,所以我怀疑它完全取决于端口设置)- 如果没有那么你将根本无法使用外部数据库。

请注意,由于网络延迟,使用异地数据库通常会导致性能非常差。您有没有使用主机提供的数据库的原因?

连接字符串格式错误。必须是

connectionString="Server=192.168.0.XX;Database=DBname;User Id=bdusername;Password=dbpassword;"