In my WebAPI application, I faced similar issue of 405 method not allowed web api
and this issue; Asp.NET Web API - 405 - HTTP verb used to access this page is not allowed - how to set handler mappings
I had to disable WebDAVModule in my web.config like below;
<modules>
<remove name="WebDAVModule"/>
</modules>
<handlers>
<remove name="WebDAV"/>
</handlers>
I do not depend explicitly to this module, but I am just wondering that would disabling this module could create any significant performance/security problems? I checked documentation below, but could not find anything specific to it.
https://learn.microsoft.com/en-us/iis/get-started/whats-new-in-iis-7/what39s-new-for-webdav-and-iis-7
Related
I'm trying to serve WebDav requests to create a CalDav server so that users can access our calendar function easily on any device of their choosing.
The problem is in trying to serve any custom headers. I've written a custom ActionResult that sets up any result easily in the right way. Upon a OPTIONS request, which gets recognized, it adds:
response.AppendHeader("Allow", "OPTIONS, PROPFIND, HEAD, GET, REPORT, PROPPATCH, PUT, DELETE, POST");
When I look into the request that the end-user receives the following header appears:
Allow: OPTIONS, TRACE, GET, HEAD, POST
When I then try to do a request with the custom header PROPFIND it simply returns a 404 error. I tried googling but there is not a lot around about this stuff. It's probably something I have to enable or disable.
https://www.iis.net/configreference/system.webserver/httpprotocol/customheaders
please see section How To.
You can do it on multiple ways
IIS
Web.Config
Code : C#, VB.NET, JavaScript
I had to remove the WebDavModule and WebDav handler in the web config. After I had done that it worked perfectly.
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
</system.webServer>
I'm building out a series of MVC4 Web API's that return various bits of information. In most of the APIs, I'm conducting a GET method and passing a fully qualified domain name.
If I pass a short name the API returns the data as expected; however if I pass a fully qualified domain as an ID ending in ".com" I get a 404.
The API works fine when I debug within Visual Studio 2010; however once I "publish" the content, I start getting 404's. My initial hunch is that it's something with IIS; however I haven't been able to put my finger on the exact problem.
WORKS: /controller/action/server_shortname
404: /controller/action/server.domain.com
Any guidance would be appreciated. Thanks
If you are using .NET 4.0 you can use this in your web.config:
<httpRuntime relaxedUrlToFileSystemMapping="true" />
Apart from that you should also assure that you are running your applicationPool in integrated mode.
There are a few other posts that mention the same problem and depending on your configuration you could find your answer there:
How to get ASP.NET MVC to match dot (".") character at the end in a route?
ASP.NET MVC Url Route supporting (dot)
. has a special meaning in the path portion of an url and is interpreted by IIS as a extension separator.
If you are running in IIS Integrated Pipeline mode you could add the following handler to the <system.webServer> node:
<system.webServer>
<handlers>
...
<add
name="UrlRoutingHandler"
type="System.Web.Routing.UrlRoutingHandler, System.Web"
path="/api/*"
verb="*" />
</handlers>
</system.webServer>
You will only need to adjust the path="/api/*" to the endpoint that you configured your API to listen to.
I'm trying to use PUT in an MVC 4 application and I'm getting a 405 error.
In my routing I have a constraint on the route to allow PUT and POST, POST to the endpoint works, PUT fails with a 405.
I've followed the advice here ASP.NET Web API returns 404 for PUT only on some servers and here ASP.NET MVC got 405 error on HTTP DELETE request?
I've also deleted WeDAV from IIS, but I'm still getting the 405. Anybody have any other suggestions?
I'm also having exactly the same issue on IIS 8 (with Visual Studio 2012), for that I've followed this advice ASP.NET Web API - PUT & DELETE Verbs Not Allowed - IIS 8 and still no luck
My hosting provider could NOT uninstall WebDAV as this would affect everyone.
This, runAllManagedModulesForAllRequests="true" , worked but was not recommended.
Many fixes included removing the module for WebDAVModule but that still didn't work. I removed the handler also, and finally I could use all verbs POST GET PUT DELETE.
Remove WebDAVModule and WebDAV in modules and handlers.
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
As I said above I'm using the WebAPI and it appears that the WebAPI is 'fussy' over which verbs map to which methods. I ended up having to add the [HttpXXX] attributes (HttpPut, Get, Delete and Post) to the appropriate methods to get the routing to work as I expected it to.
Putting my 2 cents in... Clicking on my site under iis showed 'WebDAV Authoring Rules' as the last entry under 'IIS'. Double-clicking on that showed 'The WebDAV feature has been disabled.' alert on the right and there was a link for 'Enable WebDAV' but it still didn't work. I followed Stanomatic's suggestion above, the handlers section didn't matter, and my modules looked like this:
<modules runAllManagedModulesForAllRequests="true" />
I just added the remove in it and that fixed my problem:
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
I have created a HttpHandler that I would like to use with my asp.net mvc application (the version of mvc is not relevant). How do I make my HttpHandler to handle request to a certain directory? The actual file in the directory doesn't exist, but that is fine since I want to create the response. I want it to work in IIS 7 of course, but also in Visual studio for debugging purpose. When searching the internet for it I found that you register handlers in web.config under the system.webServer node like:
<system.webServer>
<handlers>
<add name="MyHandler" path="/MyPath/*" verb="*" type="Namespace.To.MyHandler" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>
But my handler doesn't get fired.
Ok, so it turned out that this is not what I want to do at all. What I ended up doing was creating my custom IRouteHandler and mapped a route to the folder I wanted my handler to use. My custom IRouteHandler only created a new instance of my already existing IHttpHandler, since I could use the same one. I will provide more info here later on.
I'm trying to pass the DELETE to a URL in asp.net MVC using JavaScript but however i always got 405 Method not allow return.
is there anyway to make this work?
FYI: I've put the [AcceptVerb(HttpVerb.Delete)] attribute on my controller.
DELETE /post/delete/8
this is the request
It was frustrating to me too. It is because WebDAVModule is installed by default on IIS 7.5. By removing the module, you can get rid of this frustrating restriction. Simply,
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule"/> <- add this
from http://shouldersofgiants.co.uk/Blog/post/2009/11/27/HTTP-Error-405-With-ASPNet-MVC-and-HTTP-PUT-on-IIS-75.aspx
You should check the web.config (if using IIS7, else the IIS manager for IIS6 and below) to make sure the DELETE verb is mapped to the MCV request handler.