SharePoint 2010 ashx 处理程序匿名访问

发布于 2024-11-14 10:40:15 字数 244 浏览 4 评论 0原文

我在网上看到了大量有关如何通过继承 UnsecuredLayoutsPageBase 等来允许匿名访问特定 SharePoint 应用程序页面的信息。

如何为位于布局目录中的 ashx 处理程序实现相同的功能?默认情况下,SP 将需要身份验证才能访问处理程序。我可以通过允许匿名访问网站本身来解决这个问题,但我无法摆脱这个......我只需要匿名访问处理程序。我尝试将 web.config 文件粘贴在与处理程序相同的目录中并允许匿名访问,但这仍然不起作用。

I've seen plenty of information on the web about how to allow anonymous access to a specific SharePoint Application page by inheriting from UnsecuredLayoutsPageBase, etc.

How can I achieve the same thing for an ashx handler that lives in the layouts directory? By default, SP will require authentication to get to the handler. I can get around this by allowing anonymous access to the site itself, but I can't get away with that...I need anonymous access to only the handler. I have tried to stick a web.config file in the same directory as the handler and allow anonymous access there, but that still doesn't work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

征棹 2024-11-21 10:40:15

我也有同样的情况。您表示您“无法摆脱 [...] 允许匿名访问网站本身”,所以我不确定我的解决方案是否适合您,但它是:

  1. 打开对 SharePoint 的匿名访问(http://www.topsharepoint.com/enable-anonymous-access-in-sharepoint-2010)
  2. 在 IIS 管理器中,打开对包含 ashx 文件的布局子文件夹的匿名身份验证。 (SharePoint 似乎仍然需要对应用程序页面进行身份验证,因为它们是从 LayoutsPageBase 扩展的)。

或者,在我的开发网站上,我启用了 SharePoint 匿名访问,打开了 IIS 管理器的匿名访问,然后创建了 2 个 web.config 规则。

<system.web>
    <authorization>
        <deny users="?" />
    </authorization>
    ...
</system.web>
<location path="_layouts/Folder/Anonymous.ashx">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
</location>

但是,我认为该版本过于复杂。我更喜欢第一个选择。

I had the same situation. You stated that you "can't get away with [...] allowing anonymous access to the site itself", so I'm not sure if my solution will work for you, but here it is:

  1. Turn on Anonymous Access to SharePoint (Steps 1 - 6 of http://www.topsharepoint.com/enable-anonymous-access-in-sharepoint-2010)
  2. In IIS manager, turn on Anonymous Authentication to the layouts subfolder that contains your ashx file. (SharePoint appears to still require authentication to application pages because they extend from LayoutsPageBase).

Alternatively, on my dev site I enabled SharePoint Anonymous Access, turned on anonymous access from IIS manager, and then created 2 web.config rules

<system.web>
    <authorization>
        <deny users="?" />
    </authorization>
    ...
</system.web>
<location path="_layouts/Folder/Anonymous.ashx">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
</location>

However, I think that version is overcomplicated. I prefer the first option.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文