문제

I have an application in which I am using OData and Knockout Js. In my application I am using POST, GET and DELETE HTTP Verb and when I hosted my application, the GET and POST doesn't throw any error but DELETE does throw an error, not sure how to fix it.

Following is where I am using 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'
            });
        }
    }

And the error is

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

How do I fix it

도움이 되었습니까?

해결책 2

Even Adding the below lines to my web.config helped me

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="WebDAVModule"/>
    </modules>

다른 팁

Try to modify your request:

$.ajax({
    url: '/odata/Canadiancrudes(' + canadiancrude.Id + ')',
    type: 'DELETE',
    dataType: 'json',
    headers: { 
        "Content-Type": "application/json",
        "X-HTTP-Method-Override": "DELETE" }
});

Also, if you use IIS you could do next steps:
1) In Control Panel, click Programs and Features, and then click Turn Windows Features on or off.
2) Expand Internet Information Services, then World Wide Web Services, then Common HTTP Features.
3) Unselect WebDAV Publishing, and then click OK.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top