Quote:I have an issue regarding web api for Change pwd it is working properly in fiddler but when i call it through ajax after submitting form it shows error as "HTTP Error 405.0 - Method Not Allowed"
<pre>// Cotroller [HttpPut] public HttpResponseMessage Put([FromUri]string oldPwd, [FromBody]Hotel_Login Hotel_Login) { using (Hotel_ShowEntities entities = new Hotel_ShowEntities()) { try { var entity = entities.Hotel_Login.FirstOrDefault(e => e.Password == oldPwd); if (entity == null) { return Request.CreateErrorResponse(HttpStatusCode.NotFound, "Customer with that Password=" + oldPwd.ToString() + "not found"); } else { entity.Password = Hotel_Login.Password; entities.SaveChanges(); return Request.CreateResponse(HttpStatusCode.OK, entity); } } catch (Exception ex) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex); } } } //Ajax call $(document).ready(function () { $("#btnSubmit").click(function () { var CurrentPwd = $("#CurrPwd").val(); var Newpwd = $("#NewPwd").val(); console.log(Newpwd); $.ajax({ type: "Put", url: "http://localhost:16580/api/ChangeForgetPass/Put?oldPwd=" + CurrentPwd, contentType: "application/json", dataType: "json", processData: true, data: '{"Password":"' + Newpwd + '"}', success: function (s) { alert("Password Changed successfully"); }, }); }); });
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)