Я сталкиваюсь с "Http fail response" для метода put, когда я пытаюсь обновить свои пользовательские детали на странице userdetails моего приложения angular 2.Может ли кто-нибудь дать мне идею исправить следующую ошибку.
Ошибка: - Сообщение: «Запрашиваемый ресурс не поддерживает http-метод« PUT ».»сообщение: «Http-сообщение об ошибке для http://localhost/TestWebAPI/api/UserDetails: 405 метод не разрешен»
userdetails.component.ts
onUpdateUserClick(index)
{
this.objuserservice.UpdateUser(this.UpdateUser).subscribe
(
(response) => {
this.UpdateUser = response;
this.userslist[this.updateIndex].email = this.UpdateUser.email;
this.userslist[this.updateIndex].personname = this.UpdateUser.personname;
this.userslist[this.updateIndex].mobile = this.UpdateUser.mobile;
this.userslist[this.updateIndex].dateofbirth = this.UpdateUser.dateofbirth;
this.userslist[this.updateIndex].monthofbirth = this.UpdateUser.monthofbirth;this.userslist[this.updateIndex].yearofbirth=this.UpdateUser.yearofbirth;
this.userslist[this.updateIndex].gender = this.UpdateUser.gender;
this.userslist[this.updateIndex].country = this.UpdateUser.country;
},
(error)=>{
});
}
users.service.ts
UpdateUser(userobj:User):Observable<User>
{
return this.http.put<User>(`/TestWebAPI/api/UserDetails`,userobj,responseType:"json"});
}
Вот мой код проекта asp.netwebapi (TestWebAPI),
public void Put(int id, [FromBody]user objuser)
{
dbentity.Entry(objuser).State = System.Data.Entity.EntityState.Modified;
dbentity.SaveChanges();
}