6

我有一个使用 http PUT 作为 .ashx 通用处理程序的 ASP.NET (.NET 4) 网站。PUT 调用源自 Silverlight 前端。在我的本地机器(Cassini Web 服务器)上的 VS 2010 中所有工作。

然后我部署到一个 IIS7.5 Win Server 2008 R2 盒子。

silverlight/网站很好,但是对 .ashx 处理程序的 PUT 调用会遇到 Windows 登录提示。
这是一个本地 Intranet,因此 Windows 身份验证(使用 NTLM 和协商提供程序)是唯一启用的身份验证。

然后我读到这个:http: //blogs.msdn.com/b/joseph_fultz/archive/2009/07/23/enabling-the-put-verb-with-handlers-and-iis-7-0.aspx

我听从了他的建议,现在可以通过我的 .ashx 处理程序进行 PUT 调用。问题是只有 Web 服务器管理员组中的人员才能执行此操作。没有其他人可以。他们会遇到 Windows 登录提示。

知道这可能是什么吗?

我无法授予公司网络服务器上的每个人的管理员权限。毫无疑问,他们会砍掉我的一只手,在我面前吃掉我说的那只手,然后带我开门。

4

1 回答 1

9

好的,我想通了。

以下是 IIS 7.5 中的关键配置元素:

  1. 在 Windows 身份验证/提供程序下 - NTLM 必须在协商之上
  2. 域用户需要对包含 ashx 处理程序的目录的写入权限
  3. URL 授权未作为 Web 服务器上的角色启用。我添加了它,然后将它卡在 system.webServer 下的 web.config 中:

    <security>
        <authorization>
            <remove users="*" roles="" verbs="" />
            <add accessType="Allow" users="*" verbs="GET,HEAD,POST,PUT,DELETE,DEBUG" />
        </authorization>
    </security>
    

(我会稍微修剪一下,但现在它可以工作)

我的整个 system.webServer 元素如下:

<system.webServer>
    <modules>
        <remove name="WebDAVModule" />
    </modules>
    <defaultDocument>
        <files>
            <clear />
            <add value="default.aspx" />
        </files>
    </defaultDocument>
    <handlers accessPolicy="Read, Write, Execute, Script">
        <remove name="WebDAV" />
        <remove name="SimpleHandlerFactory-Integrated-4.0" />
        <remove name="SimpleHandlerFactory-Integrated" />
        <add name="SimpleHandlerFactory-Integrated" path="*.ashx" verb="GET,HEAD,POST,DEBUG,PUT" type="System.Web.UI.SimpleHandlerFactory" resourceType="Unspecified" requireAccess="Write" preCondition="integratedMode" />
        <add name="SimpleHandlerFactory-Integrated-4.0" path="*.ashx" verb="GET,HEAD,POST,DEBUG,PUT" type="System.Web.UI.SimpleHandlerFactory" resourceType="Unspecified" requireAccess="Write" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    <security>
        <authorization>
            <remove users="*" roles="" verbs="" />
            <add accessType="Allow" users="*" verbs="GET,HEAD,POST,PUT,DELETE,DEBUG" />
        </authorization>
    </security>

</system.webServer>

做到了。

于 2011-07-19T12:31:25.737 回答