When I am connecting to mysql in go daddy from my asp.net mvc application . I am getting bad request error. May I know how to debug it? The thing is when I tried the same having mysql in my local machine . It worked for me.The following is code from my 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>")
});
The following is the code form my mvc asp.net application
My Interface method
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "GetSportsList/")]
List<Sport> GetSportsList();
the following code is from my implementation class
public List<Sport> GetSportsList()
{
List<Sport> sports = new List<Sport>();
sports = readSportsFromDB();
return sports;
}
In the following method , I am reading from database
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;
}
I am getting the following error
Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
The following is the error screen shot . and one more point I want to make , I am able to attach the debugger , and found that it is not even hitting GetSportsList() in my code.