I am trying to create HttpDeleteservice in my Web Api but its not working and giving me the follwoing error
Handler "WebDAV" has a bad module "WebDAVModule" in its module list
My service code implemented as follows
[HttpDelete]
public string DeleteItem(long itemId)
{
try
{
// Implementation goes here
}
catch (Exception ex)
{
throw ex;
}
}
I am using the following http request using Postman plugin using HTTPDelete method
http://localhost:85/RM.Services/api/Item/DeleteItem?itemId=12
I used the following configuration to solve this issue at web.config
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
</system.webServer>
also trying the following settings in web.config
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
</system.webServer>
but nothing work for me the same error appears
I tried to remove WebDav from IIS with the following steps
go to Control Panel then Programs and Fetures then Turn windows features on or off
then Internet Information Services then World Wide Web Services then Common HTTP Features
then remove WebDav Features
In this case i recieved 404 error
Any help in this issue?
In Web API you shouldn't put action DeleteItem in your URL, here the routing is different from MVC. You should call using HTTPDelete method and use this url:
http://localhost:85/RM.Services/api/Item/12
i removed the following configuration from Web.config
<modules>
<remove name="WebDAVModule" />
</modules>`
and keep
<handlers>
<remove name="WebDAV" />
</handlers>
and now everything is working fine
Related
I have got a new iis server and from a while i am finding solution for error :
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.
I have seen below solutions:
1.
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
</system.webServer>
2. IIS Settings http://www.somacon.com/p126.php
Solution 1, causes Internal server error and later unable to find the solution.
Solution 2, i am unable to find Property window in iis 8.5, so unable to try the same.
Please help
I also had the same internal server error when attempting the first solution, described at HTTP 405 error with Web API. Since I wasn't even using WebDAV, I opted to remove it entirely from IIS (see screenshot below). After a required server restart, the problem was resolved.
One of my colleague helped me out. I was missing some of the major iis features.
Goto Add Roles and Features Wizard, then Web Server (IIS)> Web Server > Application Development > Select ASP.net 3.5 and Asp.net 4.5 and click Install.
Goto cmd prompt and iisreset.
For WCF service, Kindly check Http Activation under WCF Services.
Hope this may help you and save your time.
This is late but may help some other guys.
My application is WEB-API dotnet Core face same problem when deploy on local server resolve this by doing following steps.
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule"/>
<!-- add this -->
</modules>
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="TRACEVerbHandler" />
<remove name="OPTIONSVerbHandler" />
<remove name="WebDAV" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="aspNetCore" path="*" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
</handlers>
I have faced the same issue with with my PHP application that runs on "Windows server 2019" and IIS server. I tried to test my FHIR APIs through Postman but only POST and GET request were working fine. But PUT requests were not working. Any solutions that were suggested to do on web.config file were not worked for me.
Only solution was to remove "WebDAV" module from IIS (as suggested by Mark G). Restarting the server machine is a MUST to apply that feature removal and make my application to work properly.
I'm working with C# Web Api and AngularJs. If I add
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
The delete request works from fiddler, but when it comes to call it from angularJs i got an error that Options is not define. The options call is done by default by angular.
If I don't add the code form above the HttpDelete does not work. I got a response header like:
Allow: GET, HEAD, OPTIONS, TRACE
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
I am using $resource to call the web api from AngularJS. The web.config from web api with removed webDavModule looks like:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule"/>
</modules>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="TRACEVerbHandler" />
<remove name="WebDAV"/>
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="X-Requested-With, accept, content-type" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
</customHeaders>
</httpProtocol>
</system.webServer>
The request on google chrome looks like: this
Do you have any idea why I've got this issue?
It seems to be you are hosting your AngularJs application on localhost:<port>. Your Web Api must respond with Access-Allow-Control-Origin containing your localhost:<port>.
When you are hosting on different port your browser sends a pre-flight request with HTTP OPTIONS. Web API must allow HTTP OPTIONS verb as well.
http://www.html5rocks.com/en/tutorials/cors/
You can also look inside of Chrome Developer Tools console. Chrome must write an error message in this case to a console. It answers to you HTTP 405 it means OPTIONS HTTP Verb is not allowed, despite it is in response Access-Control-Allow-Headers headers. IIS adds HTTP headers but HTTP 405 comes from your services.
For example, in my OAuth/JWT service implementation I had needed to write logic to respond HTTP 200 on OPTIONS verb on dev environment because of strange constellation of Chrome + localhost:<port> and preflight requests.
I'm trying to deploy a WebAPI project to Azure.
It works locally. When I Publish it to Azure, I get 404 on the controller routes.
Looking at the logs, I see the routes are being handled as static files, instead of going through my controllers.
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Requested URL http://xxxxx:80/api/studies
Physical Path D:\home\site\wwwroot\api\studies
Logon Method Anonymous
Logon User Anonymous
My Global.asax is:
protected void Application_Start()
{
GlobalConfiguration.Configure(WebApiConfig.Register);
}
And my WebApiConfig.Register is:
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
I've looked at similar questions and tried tweaking my Web.config to no avail. It currently looks like this (relevant part only):
<system.webServer>
<httpErrors existingResponse="PassThrough"/>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
</modules>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
By the way, I'm on Entity Framework 6 and not using MVC, just straight up WebAPI.
Somehow my Global.asax got excluded from the project, so the route mapping never happened.
I had the same issue. nothing else worked until changing my web config to look like this solved it for me
<handlers>
<remove name="WebDAV" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
Have you checked all the necessary Windows Features for your server? Maybe some features are missing from IIS, for example:
Internet Information Services - World Wide Web Services - Application Development Features - ASP.NET.
You can find and check which features are installed on your machine by going to Windows Features (or going through the Server Manager if you're on a Windows Server).
If that is not your problem, it can sometimes be that ASP.NET is not installed properly. You can re-install ASP.NET by following this article: http://support.microsoft.com/kb/2736284 (it depends on your operating system).
I have a web application which talks to a local service (also mine) and produces results from the RESTful calls.
I have deployed the web application through IIS 7 on my system.
So far it looks fine, except that I am not able to perform POST operations, they just seem like NOP's.
Although, when I install VS 2012 on the machine the POST operations start working. I am not sure what exact thing the VS 2012 install sets which causes the POST operations to work.
Any hints?
You have to enable POST operations in your web.config file. A simple implementation is demonstrated below
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
Make sure to inlcude this in your config file:
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
i am pretty new to MVC and Routing and i was asked to modify an app to use diffrent url's.
a task that is a bit over me since i have no experience.
ok, lets talk a bit of code:
routes.MapRoute(
"CategoryBySeName", // Route name
"products/{SeName}", // URL with parameters
new { controller = "Catalog", action = "CategoryBySeName" }
);
this works as expected, but then the client wanted ".html" at the end of paths, so i changed:
"products/{SeName}", // URL with parameters
to:
"products/{SeName}.html", // URL with parameters
which fails ( IIS 404 page - MapRequestHandler)
it seems like iis is trying to load a physical file with that name instead of passing it to the application.
Similar: ASP.NET MVC Routing to start at html page (not answered, Not duplicate)
You have to force all request through the ASP.NET pipeline, and you can do that by adding only this single line to the web.config of your application:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
You're guess that an IIS handler is probably grabbing the request prior to MVC is likely correct.
Assuming IIS 7:
http://technet.microsoft.com/en-us/library/cc770990(v=ws.10).aspx
You need to edit the .html handler in IIS to use ASP.NET.
You can find it in the website properties under the home directory tab in app configuration in the mappings section in II6.
Something along the lines of (version may be different):
C:\windows\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll is what you need to handle the .html files.
Changing the Application Pool from Classic to Integrated fixed the issue.
thank you guyz for your help.
Just add this section to Web.config, and all requests to the route/{*pathInfo} will be handled by the specified handler, even when there are dots in pathInfo. (taken from ServiceStack MVC Host Web.config example and this answer https://stackoverflow.com/a/12151501/801189)
<location path="route">
<system.web>
<httpHandlers>
<add path="*" type="System.Web.Handlers.TransferRequestHandler" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" />
</httpHandlers>
</system.web>
<!-- Required for IIS 7.0 -->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<add name="ApiURIs-ISAPI-Integrated-4.0" path="*" type="System.Web.Handlers.TransferRequestHandler" verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
</location>