当我从我的asp.net mvc应用程序中连接到mysql的时候。 我收到了错误的请求错误。我可以知道如何调试吗? 问题是当我在本地机器上尝试使用mysql时。它对我有用。以下是我的html page.function
中的代码GetSupportedSports() {
if (ajaxRequest != null) {
ajaxRequest.abort();
}
var val =0;
// ajaxRequest = $.getJSON("http://localhost:8078/SportsClubDefault.svc/getsportslist/", null,
ajaxRequest = $.getJSON("http://<mydomain>/sportsVD/SportsClubDefault.svc/getsportslist/", null,
function (data) {
$.each(data,function(i,item){
val = 1;
$('#sportsName').append("<div class='container' style='padding-top: 5%';><span>"+item.Name+"</span></div>")
});
以下是我的mvc asp.net应用程序的代码形式
我的界面方法
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "GetSportsList/")]
List<Sport> GetSportsList();
以下代码来自我的实现类
public List<Sport> GetSportsList()
{
List<Sport> sports = new List<Sport>();
sports = readSportsFromDB();
return sports;
}
在以下方法中,我正在从数据库中读取
private List<Sport> readSportsFromDB()
{
MySqlConnection con = new MySqlConnection();
string ConnectionString = "server=<go daddy database server>;user id=<database username > ;password=pwd;persistsecurityinfo=True;database=<database name>";
con.ConnectionString = ConnectionString;
MySqlCommand cmd = con.CreateCommand() as MySqlCommand;
cmd.CommandText = "select * from supportedsports";
try
{
con.Open();
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
MySqlDataReader reader = cmd.ExecuteReader() as MySqlDataReader;
List<Sport> sports = new List<Sport>();
while (reader.Read())
{
Sport temp = new Sport();
temp.Name = reader["sportName"].ToString();
sports.Add(temp);
}
return sports;
}
我收到以下错误
请求获得类型&System; System.Security.Permissions.SecurityPermission,mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089&#39;失败。