0

I am using PUT for a method in RESTful service its throwing error 405 gone through all posts in google changed IIS config setting but not working.

Bala
  • 1
  • 1
  • Show us your code, it could help. – Aracthor Jul 08 '15 at 10:40
  • I have uninstalled IISExpress and re-installed changes ApplicationHost .config file but still URL doesn't work through browser. But its work through fiddler, chrome RestEasy plugin and I can use URL from other .Net applications its works as expected. – Bala Jul 10 '15 at 12:18

1 Answers1

0

Before someone marks it as a duplicate I have been dealing with this issue for a couple of days, and none of the suggested procedures in the following posts helped:

Method 1

Yet another method

You can find more examples, most of them referring the webdav module (I don't have reputation to give more references). Even if many report that it solved the issue, for some reason it did not solve for me, and since the question keeps being posted to SO I guess I am not the only one fighting this issue. Here is the way I managed to have the DELETE, PUT, OPTIONS verbs working (in both express and IIS8.5). It was as simple as adding a new mapping handler for the ProtocolSupportModule, or in web.config terms:

<add name="OtherVerbsHandler" path="*" verb="PUT,DELETE,OPTIONS" modules="ProtocolSupportModule" />

Do not use that handler also for the remaining verbs, since it won't be able to load the static files (if nothing else). Please note that I am new to ASP.NET and any insightful comments about my solution are welcome.

EDIT: This work-around actually did not solve it for me, since the DELETE request is not handled by the proper controller/action, returning always 200 OK. However, fiddling around with other API I found out the solution. I was just missing the Options method (returning always 200 OK) that in the case of this other API I already implemented because of some pre-flight requests. I still don't know why one couldn't see that this was the problem in the error output, but my API is working fine now.

//This is necessary for browsers that isssue preflight requests
//Even with CORS enabled!
public HttpResponseMessage Options()
{
            return Request.CreateResponse(HttpStatusCode.OK, "Options route activated.");
}

public HttpResponseMessage Delete(string project, string runId)
{
            return Request.CreateResponse(HttpStatusCode.NotImplemented, "Delete route activated.");
 }
Community
  • 1
  • 1
rll
  • 5,509
  • 3
  • 31
  • 46