0

Things tried:

  1. commented lines regarding webdav
  2. edited iis config file i.e added PUT,DELETE verbs
  3. jQuery .support.cors = true;

Error: 405: method not allowed (in chrome debugger) response is going to ajax error.

ajax call code:

jQuery.support.cors = true;
function CheckLogin() {
  var user = { "UserName": $('#UserName').val(), "Password": $('#Passsword').val() };
  user = JSON.stringify(user);
  $.ajax({
    url: 'http://localhost/MvcRazorClient/api/HomeApi/SignIn',
    //here i changed the webapi route to api/controller/action 
    type: "PUT",
    data: user,
    async: false,
    crossDomain: true,
    contentType: "application/json",
    dataType: 'json',
    success: function (data) {
      if (data == true) {
        alert('true')
      } else {
        alert('false');
      }
    },
    error: function () {
      alert('er');
    }
  });
}

my api controller code:

[HttpPut]
public bool SignIn(User u)
//here i tried parameters as "dynamic u" and "HttpRequestMessage u". nothing worked
{
   return true;
}

help please.

peinearydevelopment
  • 11,042
  • 5
  • 48
  • 76
kuna
  • 25
  • 1
  • 8
  • Which version of web API are you using ? Are you targeting .NET 4 or 4.5 ? Also make sure you don't have WebDAV installed http://stackoverflow.com/questions/19162825/web-api-put-request-generates-an-http-405-method-not-allowed-error – Francis Ducharme Mar 11 '15 at 15:34
  • net 4.5 and i dont have webdav @ Francis Ducharme – kuna Mar 12 '15 at 04:30

1 Answers1

0

i didnt disable webDAV in iis . path: Control Panel\All Control Panel Items\Programs and Features->iis->world wide web services->Common Http Features->(uncheck) webDAV

kuna
  • 25
  • 1
  • 8