【问题标题】:How do I allow anonymous access to my mvc3 app using Windows Authentication如何使用 Windows 身份验证允许匿名访问我的 mvc3 应用程序
【发布时间】:2012-07-14 13:09:09
【问题描述】:

我有一个使用 Windows 身份验证的 MVC3 Intranet 应用程序。我现在正在使用第三方服务,它将向我的应用程序发出通知调用。我已经为这些 API 调用创建了一个侦听器,但不确定如何允许匿名访问我的应用中的单个视图。

我的IIS7设置如下:

Anonymous - Enabled <---------- Use Domain User
ASP.NET Impersonation - Disabled
Basic Authentication - Disabled
Digest Authentication - Disabled
Forms Authentication - Disabled
Windows Authentication - Enabled - HTTP 401 Challange

另外,在我的 web.config 文件中,身份验证模式设置为 Windows。

话虽如此,有没有办法允许匿名访问我的 MVC 应用程序中的单个视图?

【问题讨论】:

  • 你找到解决方案了吗?
  • @BongoSharp 这个问题太老了!!!我认为下面的答案是最好的解决方案。

标签: asp.net-mvc-3 iis windows-authentication anonymous-access


【解决方案1】:

路径是您的最终 url,将其添加到您的 web.config。

<location path="MyController/MyAction">
    <system.web>
        <authorization>
            <allow users="?" />
        </authorization>
    </system.web>
</location>

或者用 AllowAnonymousAttibute http://msdn.microsoft.com/en-us/library/system.web.http.allowanonymousattribute(v=vs.108).aspx 装饰动作。

【讨论】:

    猜你喜欢
    • 2020-07-01
    • 2019-09-16
    • 2023-04-09
    • 1970-01-01
    • 2018-04-30
    • 2011-06-04
    • 1970-01-01
    • 2012-03-25
    • 2015-12-05
    相关资源
    最近更新 更多