我在使用 C# 中的连接字符串时遇到问题
数据库通过phpmyadmin在服务器上(我不拥有在线服务器)
通过 GoDaddy 和 GlobeHost 获得了托管,但都遇到了同样的问题
我当前的连接设置是 string strcon = "Server=ipAddress(OfServer);Database=testing;Uid=myusername;Pwd=mypassword";
我在 Connection.Open();
检查链接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.
最佳答案
您的网络托管服务商已将服务器配置为阻止出站连接,至少特别针对您的网站以及可能的端口号。
与您的网络托管服务商联系,了解您是否可以被授予权限,或者其他端口是否未被阻止(虽然这是代码访问安全配置,所以我怀疑它完全取决于端口设置)——如果没有,那么您将根本无法使用外部数据库。
请注意,由于网络延迟,使用异地数据库通常会导致性能非常差。您有没有使用主机提供的数据库的原因?
关于c# - 安全异常 ASP.NET/MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39250935/