简体   繁体   English

放置方法抛出500错误ASP.NET MVC 5

[英]Put method throws 500 error ASP.NET MVC 5

I'm using something like REST API on my web site. 我在网站上使用的是REST API。 And I'm using PUT method. 我正在使用PUT方法。

[HttpPut]
 public ActionResult OrderChapter(ClientOrder order)

But it's not Web API, it's MVC controller. 但是它不是Web API,而是MVC控制器。 At first I was receiving 405 error (Method Not Allowed). 起初,我收到405错误(不允许使用方法)。 Google said that I need to remove the WebDAVModule Google说我需要删除WebDAVModule

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

After this I have a 500 error. 在这之后,我有一个500错误。 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. 我的主持人说,没有明确禁止PUT,PATCH和DELETE方法。

What's wrong? 怎么了? Maybe in settings of IIS this methods are not allowed? 也许在IIS的设置中不允许使用此方法?

Usually, error code #500 has to do with some internal server error and it's also its official definition. 通常,错误代码#500与某些内部服务器错误有关,这也是它的正式定义。

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). 用外行的话来说, PUT操作中的代码似乎有问题,快速调试PUT操作方法将为您提供问题的答案,可能抛出了某些异常并将其翻译为500错误代码通过您的网络服务器(例如IIS)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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