PUT + DELETE HTTP动词从API在共享主机的网络服务器返回四百零五分之四百零一 [英] PUT + DELETE Http Verbs returning 401/405 from API on shared hosting webserver

查看:228
本文介绍了PUT + DELETE HTTP动词从API在共享主机的网络服务器返回四百零五分之四百零一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个MVC的Web API进行一些大学的课程,我的开发机器上如预期(运行VS11)的作品。

I have created an MVC Web Api for some university coursework, that works as expected on my development machine (Running VS11).

然而,当我将应用程序部署到Web服务器上比GET和POST 123reg HttpVerbs其他似乎没有达到我的应用程序在所有的,最初返回401未授权响应;然而,由于建议关闭的WebDAV模块之后的这里这些401S成了不允许405方法。在这种情况下,我只禁用了处理程序作为禁用这两个处理程序和模块,这意味着我的应用程序根本不启动(不带堆栈跟踪误差500自定义错误是关闭])。

However when I deploy the application to the webserver on 123reg HttpVerbs other than GET and POST appear to not reach my application at all, initially a 401 Not Authorised response was returned; however after turning off the "WebDAV" module as suggested here these 401s became 405 Method not allowed. In this case I only disabled the handlers as disabling both the handlers and the module meant that my application did not start at all (Error 500 without a stacktrace [custom errors are off]).

我计划利用形式的成员提供身份验证功能添加到我的API,但是我删除的任何 [授权政府] 从我的code属性时401S开始出现的。

I am planning to utilise the forms membership provider to add authentication capabilities to my API, however I removed any [Authorise] attributes from my code when 401s began appearing.

在123Reg的共享主机的应用程序是根据中等信任运行。

Applications on 123Reg's shared hosting are run under Medium trust.

我一直在与123Reg支持接触,他们已经半有益的,但​​因为决定他们不能帮我(他们建议增加HttpHandlers的详情如下)(显然,我应该咨询网页设计师... )

I have been in contact with 123Reg support, and they have been semi helpful, but have since decided that they cannot help me further (They suggested adding HttpHandlers as detailed below) (Apparently, I should consult a web designer...)

我已经加入 [使用AllowAnonymous] 属性我控制器和/或行动有没有效果。

I have added [AllowAnonymous] Attributes to my controllers and/or actions with no effect.

我已经添加了授权 web.config文件属性,允许所有动词和路径,对所有用户都进行身份验证,而不是:

I have added the authorization web.config attribute allowing all verbs and paths to all users both authenticated and not:

<authorization>
  <allow users="*" />
  <allow users="?" />
  <allow verbs="*" users="*" />
  <allow verbs="*" users="?" />
</authorization>

我已经加入(如123Reg建议):

I have added (As suggested by 123Reg):

 <system.webServer>
    <handlers>
      <remove name="WebDAV" />
      <add name="PUTVerbHandler" path="*" verb="PUT" modules="ProtocolSupportModule" resourceType="Unspecified" />
      <add name="DELETEVerbHandler" path="*" verb="DELETE" modules="ProtocolSupportModule" resourceType="Unspecified" />
    </handlers>
  </system.webServer>

这似乎是一个进步,因为我们现在收到而不是401阶跃响应405的反应,但我现在无法作出任何进一步的进展。此外,我还增加了:

This appeared to be a step forward, as we now receive 405 responses rather then 401 respones, however I am now unable to make any further progress. Additionally I have also added:

<httpHandlers>
    <add verb="*" path="*" type="System.Web.Mvc.MvcHttpHandler"/>
</httpHandlers>

这也没有什么区别。

任何帮助,您可以给将是非常美联社preciated(我真的不希望有移动主机此应用程序!)

Any help you can give would be much appreciated (I dont really want to have to move host for this application!)

推荐答案

我发现这个: HTTP: //forums.iis.net/t/1163441.aspx

从这个论坛上发帖的长相,你需要为PUT完全卸载WebDAV和DELETE动词来工作。这不会帮助一个共享的虚拟主机方案很遗憾。

From the looks of that forum post, you need to completely uninstall WebDAV for the PUT and DELETE Verbs to work. This is not going to help on a shared webhosting scenario unfortunately.

这篇关于PUT + DELETE HTTP动词从API在共享主机的网络服务器返回四百零五分之四百零一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆