asp.net mvc - IIS 8.5 server 2012 not returning json -


at localhost iis express, doesn't give me error, when copy iis 8.5 on server 2012, gives me "internal server error 500" when request json result.

here code.

controller

        [httpget]     public jsonresult ticketsabertos(string username)     {          computer computer = new computer();         computer.gethostdetails();           //return json(jsonconvert.serializeobject(result), jsonrequestbehavior.allowget);         string json = jsonconvert.serializeobject(computer.getopentickets(computer.user));         return json(json, jsonrequestbehavior.allowget);         // return this.json(computer.getopentickets(computer.user), jsonrequestbehavior.allowget);     } 

model

public list<computer> getopentickets(string user_)     {          list<computer> listar = new list<computer>();         dictionary<string, string> list = new dictionary<string, string>();         //int result;         string connetionstring = null;         sqlconnection cnn ;         connetionstring = "data source=.\\helpdesk;initial catalog=" + db + ";user id=" + user_db + ";password=" + pwd + "";         cnn = new sqlconnection(connetionstring);         try         {             cnn.open();             string query = "select * [tbl_user_details] join [tbl_assistance_description] on [tbl_user_details].username @user_ , [tbl_assistance_description].status @status_ order [tbl_assistance_description].date desc";             try             {                 sqlcommand command = new sqlcommand(query, cnn);                 command.parameters.addwithvalue("@status_", "aberto");                 command.parameters.addwithvalue("@user_", user_);                 try                 {                     sqldatareader datareader = command.executereader();                     if (datareader.hasrows)                     {                         while (datareader.read())                         {                             try                              {                                  listar.add(new computer()                                 {                                     //id = datareader.isdbnull(0) ? convert.toint32(null) : datareader.getint32(0),                                     user = datareader.isdbnull(1) ? null : datareader.getstring(1),                                     host = datareader.isdbnull(2) ? null : datareader.getstring(2),                                     ip = datareader.isdbnull(3) ? null : datareader.getstring(3),                                     location = datareader.isdbnull(4) ? null : datareader.getstring(4),                                     id = datareader.isdbnull(6) ? 0 : datareader.getint32(6),                                     report = datareader.isdbnull(7) ? null : datareader.getstring(7),                                     description = datareader.isdbnull(8) ? null : datareader.getstring(8),                                     date = datareader.getdatetime(10).tostring(),                                     status = datareader.isdbnull(11) ? null : datareader.getstring(11)                                 });                              }                             catch (sqlexception ex)                             {                                 listar.add(new computer()                                 {                                 db_result = ex.message                                 });                             }                         }                     }                 }                 catch (sqlexception ex)                 {                     listar.add(new computer()                     {                         db_result = ex.message                     });                 }                 cnn.close();             }             catch (sqlexception ex)             {                 listar.add(new computer()                 {                     db_result = ex.message                 });             }         }          catch (sqlexception ex)         {             listar.add(new computer()             {                 db_result = ex.message             });         }         return listar;       } 

ajax request

 $("#aticketsabertos").live("click", function (evt) {     $(".featured .content-wrapper").slideup();     $("#adminmenu").hide();     var result = "";     $("#result").fadeout();     evt.preventdefault();      $("#indexform").hide();     $("#ticketsabertos").show();     $("#ticketsfechados").hide();     $(".featured .content-wrapper").slidedown();     $.ajax({         type: "get",         url: "helpdesk/home/ticketsabertos",         //data: { username: $("#user").val() },         //jsonp: false,         datatype: "json",         contenttype: "application/json",         success: function (output) {             output = json.parse(output);             $("#result").show();             console.log(output);             $.each(output, function (i, item) {                     if (item.db_result != "") {                         result += item.db_result;                     } else {                         result += "<tr>" +                             //"<th>user</th><td>" + item.user + "</td>" +                             //"<th>host</th><td>" + item.host + "</td>" +                             //"<th>ip</th><td>" + item.ip + "</td>" +                             "<td>" + item.id + "</td>" +                             "<td>" + item.report + "</td>"+                             "<td>" + item.description + "</td>" +                             "<td>" + item.location + "</td>" +                             "<td>" + item.date + "</td>" +                             "<td class='statusaberto'>" + item.status + "</td>" +                             "</tr>"                         ;                     };             }),                 $("#result").removeclass().addclass("result_table").fadein().html("<table><tr>"+                     "<th>id</th><th>tipo</th><th>descrição</th><th>local</th><th>data</th><th>status</th>" + result + "<table>");          },         error: function (xhr, textstatus, jqxhr) {              $("#result").fadein();             $("#result").removeclass().addclass("result_error").text("erro:" + xhr.status + " " + xhr.statustext + " " + displayerror(xhr));             console.log(displayerror(xhr));         }      });     return false; }); 

the response header it's "text/html", instead json. mime type .json it's added.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -