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.
Related
I have a .net mvc application(standard) and trying to implement custom errorhandling using httpErrors in web config.
<system.webServer>
<httpErrors errorMode="Custom" existingResponse="Replace" defaultResponseMode="Redirect">
<clear />
<error statusCode="404" path="http://localhost/E_HealthCare_Web/Views/Error/NotFound404" responseMode="Redirect" />
</httpErrors>
</system.webServer>
although it redirect to specified path but I get a http 403 error stating You do not have permission to view this directory or page. I think its an iis error but don't know how to solve it. if it needs a permission then where should I go to get the permission or should I set it up.
EDIT
as mentioned in the comment i tried using absolute Url and i got localhost redirected you too many times error and i tried clearing cookies as i tried clearing cookies but its not working and it is redirecting to the same page infinitely as you can see below.
Another Edit
Thanks to #LexLi and #JennyDai i finally solved this by changing my path in web.config to to path="http://localhost/E_HealthCare_Web/Error/NotFound404" by using mvc's proper route URL pattern.
Thanks to #LexLi and #JennyDai, I finally solved this by changing my path in web.config to to path="http://localhost/E_HealthCare_Web/Error/NotFound404" by using MVC's proper route URL pattern.
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
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'm trying to deploy a MVC application to a news Server, I have .net framework 4 and ASP.net MVC2 installed. My app pool is assigned to .net 4, integrated mode. But for some reason, the routing is not happening properly. I am getting a 404 error on links and not properly routed to the controller. What am i missing here? Is it might be order of installation of .net framework and IIS?
Your app is probably compiled against .Net Framework Version 2.0. Change your app pool to 2.0 and see if it helps.
Try this :
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
Or try to debug routing
So, if you got a 404 error that is because the global.asax is not being executed.
Check out if the IIS is configured to "Check if the Directory/File exists", cause the IIS is default configured to check first if the request exists on the server ... MVC doesn't use the 'real' path, per se.
Hope it helps ;)
EDIT
Try to log something at the time the routing is working ... I mean when the Route inside the global asax is called and check out if the mapping is called...