c# - 安全异常 ASP.NET/MySQL

标签 c# mysql asp.net security

我在使用 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/

相关文章:

c# - webconfig中的属性maxRequestLength是怎么测的

c# - ASP 网络-C# : Access controls by Id

c# - 如何声明新类型

c# - while循环用数组填充datagridview

MYSQL:使用多个字段的连接更新字段

PHP连接但无法查询MYSQL数据库

asp.net - 如何在 MVC2 应用程序上更改 HTTPS 的 HTTP 协议(protocol)?

php - 使用 MySQL 面向 future 的邻近搜索

c# - 类型或命名空间名称 'Mvc' 在命名空间 'System.Web' 中不存在(您是否缺少程序集引用?) Kentico

asp.net - 我应该如何使用 ExecutionContext 来提供我自己的上下文流?