jquery - Why is ASP.NET returning both 200 OK status Code and 405 Method Not allowed in asp.net -
i using asp.net web api post form. data being posted database. api controller returns 200ok when inspect fiddler see 405 error port number of html code. controller code
[httppost] [route("api/users/addurl")] public httpresponsemessage addurl([frombody]url url) { appid = thread.currentprincipal.identity.name; int response = url.saveurl(url.urlstring, appid, url.urlname); if (response != -14) { return request.createresponse(httpstatuscode.ok); } else { return request.createerrorresponse(httpstatuscode.badrequest, "cant save now"); } } ajax call(jquery)
$(document).ready(function () { $('#companyname').text(localstorage.getitem('companyname')); $('#appid').text(localstorage.getitem('applicationid')); $('#apikey').text(localstorage.getitem('apikey')); $('#addurl').click(function () { $.ajax({ method: 'post', datatype: 'json', url: 'http://localhost:61768/api/users/addurl', headers: { 'authorization': 'basic ' + btoa(localstorage.getitem('applicationid') + ":" + localstorage.getitem('apikey')) }, data: $('#form').serialize(), success: function (data) { alert("hey"); }, error: function () { alert("nay"); } }); }); }); note: data posted database, still both 200 , 405 error. ahd jq code alerts nay. 
Comments
Post a Comment