Asp.net mvc4 web-api를 사용하고 있습니다.
오류 404 메서드를 찾을 수 없습니다. jquery ajax를 사용하여 DelteMenu 메서드를 호출하고 있습니다. 나는 데이터를 사용하여 인수를 pssing 오전 : Jquery ajax. Model 매개 변수를 전달하면 정상적으로 작동하지만 Guid, String throwing exception : 404 method nod found. 404 오류가 발생하는 이유를 알고 있으면 알려주십시오.
//api method
public HttpResponseMessage DeleteMenu(Guid MenuId)
{
try
{
MenuDA.DeleteMenu(objMenuModel.MenuId);
return this.Request.CreateResponse(
HttpStatusCode.OK,
new
{
Success = true
});
}
catch (Exception ex)
{
ErrorLogDA.LogException(ex);
throw ex;
}
}
//Jquery ajax function
function performdeletemenu(MenuId)
{
if (confirm('Are you sure you want to delete this menu?'))
{
$.ajax({
type: 'DELETE',
url: '/api/MenuWebApi/DeleteMenu/',
data: "MenuId=" + MenuId,
success: function (data)
{
if (data.Success == true)
{
GetMenuList();
}
},
error: function (xhr, textStatus, errorThrown)
{
//window.location = JsErrorAction;
},
dataType: "json",
headers:
{
'RequestVerificationToken': JsTokenHeaderValue
}
});
}
return false;
}
문안 인사
data
을 보낼 때 설정이 작동하지 않습니다 HTTP DELETE
jQuery의 AJAX 기능을 통해. URL 자체에 Guid를 전달해야합니다 url: '/api/MenuWebApi/DeleteMenu?MenuId=' + MenuId
..
내가 이상하게 생각하는 것은 400 잘못된 요청 대신 404가 반환된다는 것입니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다