Requested resource does not support http method “PUT”
  • I am working on a ASP.NET WebAPI project.I am getting this error " Requested resource does not support http method “PUT”" when calling ajax function below.
    How do you fix this?
    //Edit // PUT: api/User/5
       var username = $('#UserName').val();
       var password = $('#Password').val();
       var email = $('#Email').val();
       var active = $('#Active').val();
       var id = $('#id').val();
       var data =
           {
               Id: id,
               UserName: username,
               Password: password,
               Email: email,
               Active: active
           };
       $('#btnedit').on('click'function () {
           $.ajax({
               type: 'PUT',
               url: url,
               data: JSON.stringify(data),
               headers: {
                   "Content-Type""application/json"
                   // ,"X-HTTP-Method-Override": "PUT"
               },
               success:function(users)
               {
                   alert('Updated');
               },
               error:function(err)
               {
                   alert(err.responseText);
               }
           });
       });

  • 3 Comments sorted by
  • The method decoration is:
      [System.Web.Http.HttpPut]
          [ResponseType(typeof(void))]
          public async Task<IHttpActionResult> PutUsers(int id, Users users)
    And web.config

          <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
  • Thanks.I worked on my computer at home but it did not work on my computer at work because of settings.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Tagged

Popular Posts of the Week

Optimum Creative