0
votes

I know I am not the first one to come across this, but I have tried all the suggested fixes and still can not get it to work. I want to use the DELETE and PUT verbs with my web.API services and DNN 7.

Here is my code for the service:

    routeManager.MapHttpRoute(moduleName, "deleteproduct", "{controller}/{action}/{ID}", New String() {"Krisis.Modules.KrisisStore.Services.Controllers"})

    ' DELETE: /deleteproduct/
    <HttpDelete> _
    <ActionName("deleteproduct")> _
    <ValidateAntiForgeryToken> _
    Public Function DeleteProduct_ById_Full(ID As Integer) As HttpResponseMessage
        Try
            ...
        End Try

    End Function

Here is my ajax call (using knockout.js for my viewmodel):

// ****** CONFIRM DELETE FUNCTION ************************************************** 
this.confirmDelete = function () {

    //delete product web.Api url
    var sURL = "http://" + window.location.hostname + "/DesktopModules/KrisisStore/api/ProductService/deleteproduct/" + self.selectedProduct().ProductId;

    jQuery.ajax({
        type: "DELETE",
        url: sURL,
        success: function (response) {

            alert('Product Removed');

        },
        error: function (xhr, ajaxOptions, thrownError) {
            alert("status: " + xhr.status + "\n" + thrownError);
            //alert('There was an error');
        }
    });

    $('#DeleteModal').foundation('reveal', 'close');
};

I get the following error:

HTTP Error 405.0 - Method Not Allowed

The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.

WHAT I TRIED:

I found This SO question and followed the accepted answer: I added the verbs to both the DNN web.config file and the IIS aplicationhost.config file as follows:

<add name="ExtensionlessUrl-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
<add name="ExtensionlessUrl-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrl-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" responseBufferLimit="0" />

One of the solutions is to make sure webDAV is disabled, but I noticed that the dnn web.config file already comments out these webDAV lines in the web.config file. SO I also commented out the lines in the applicationhost.config file.

I am going to remove webDAV from IIS to see if that helps and update my question.

QUESTION

I am still getting this error. Can someone help me figure out how to add custom verbs to the HTTP requests for DNN 7 sites on IIS 8 express.

1

1 Answers

1
votes

Okay, posted too quickly. I opened Windows program and features and then expanded IIS and unchecked webDAV. It removed it from IIS and then everything worked.

If anyone else finds this, please note that commenting out the lines in IIS did not work, I had to unistall the webDAV from IIS.

enter image description here