简体   繁体   中英

Put method throws 500 error ASP.NET MVC 5

I'm using something like REST API on my web site. And I'm using PUT method.

[HttpPut]
 public ActionResult OrderChapter(ClientOrder order)

But it's not Web API, it's MVC controller. At first I was receiving 405 error (Method Not Allowed). Google said that I need to remove the WebDAVModule

<system.webServer>
<modules>
  <remove name="WebDAVModule" />
</modules>

After this I have a 500 error. And it's not my code. Adding this changed nothing:

<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>

My hoster says that PUT, PATCH and DELETE methods are not explicitly prohibited.

What's wrong? Maybe in settings of IIS this methods are not allowed?

Usually, error code #500 has to do with some internal server error and it's also its official definition.

In layman's terms, that seems that there is something wrong with your code in the PUT action, a quick debugging of your PUT action method will give you the answer to the problem, probably some exception is been thrown and that is translated to 500 Error code by your web-server (eg IIS).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM