HTTP错误405方法不被允许与web.API错误
我知道我不是第一个遇到,但我已经尝试了所有建议的修补程序和仍然无法得到它的工作。我想用DELETE和我web.API服务和DNN 7 PUT动词。
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.
下面是我的code的服务:
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
下面是我的Ajax调用(使用我的视图模型knockout.js):
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.
我的尝试:
我发现This SO质疑并遵循公认的答案:
我加入了动词既DNN的web.config文件和IIS aplicationhost.config文件如下:
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" />
解决方案之一是确保WebDAV是残疾人,但我注意到,DNN的web.config文件中已注释掉在web.config文件中,这些WEBDAV行。所以我也注释掉在ApplicationHost.config文件的行。
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.
我会从IIS的WebDAV删除,看看是否有帮助,并更新我的问题。
I am going to remove webDAV from IIS to see if that helps and update my question.
我仍然收到此错误。有人可以帮助我弄清楚如何自定义谓词添加到IIS上8 EX preSS DNN 7站点的HTTP请求。
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.
好吧,贴得太快。我打开Windows程序和功能,然后展开IIS和unchecked WEBDAV。它从IIS中删除它,然后一切工作。
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.
如果任何人发现这一点,请注意,注释掉在IIS中的线没有工作,我不得不从IIS反安装了WebDAV的。
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.