我有一個應用程序,我在其中使用OData和Knockout Js。在我的應用程序中,我使用POST,GET和DELETE HTTP Verb,當我託管我的應用程序時,GET和POST不會引發任何錯誤,但DELETE確實會拋出一個錯誤,不知道如何解決它。無法解決網絡錯誤:405方法不允許
下面就是我使用DELETE
self.remove = function (canadiancrude) {
var conf = confirm("Are you sure you want to delete this record?");
if (conf == true) {
$.ajax({
url: '/odata/Canadiancrudes(' + canadiancrude.Id + ')',
type: 'DELETE',
contentType: 'application/json',
dataType: 'json'
});
}
}
和錯誤是
405 - HTTP verb used to access this page is not allowed.
The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.
"NetworkError: 405 Method Not Allowed
如何解決呢
這是否方法具有[授權]屬性? –
是的,控制器方法的[授權]屬性的整個頁面不僅爲這個DELETE,他們工作正常 – DoIt
可能是一個CORS的問題......這是SO文章的幫助嗎? http://stackoverflow.com/questions/19675835/networkerror-405-method-not-allowed-on-google-contact-delete –