【问题标题】:How do I opt out of authentication when using identityServer?使用 identityServer 时如何选择退出身份验证?
【发布时间】:2013-02-26 01:03:03
【问题描述】:

我正在尝试 WIF 并使用 identityServer。我的问题是如何选择要求对控制器或控制器方法进行身份验证( ASP.NET MVC 4 )。我以前使用过 [AllowAnonymous] 属性。任何人都有如何做到这一点的任何样本?此代码仍会重定向到 identityServer 进行登录。

public class HomeController : Controller
{
    //
    // GET: /Home/
    [AllowAnonymous]
    public ActionResult Index()
    {
        return View();
    }

}

【问题讨论】:

    标签: asp.net-mvc-4 wif


    【解决方案1】:

    此代码仍会重定向到身份服务器进行登录。

    我希望您没有在 web.config 中添加以下内容,对吗:

    <authorization>
        <deny users="?" />
    </authorization>
    

    大多数 WIF 教程都展示了这一点,但如果您正在编写 ASP.NET MVC 应用程序,则应使用 [Authorize][AllowAnonymous] 属性控制授权。

    【讨论】:

    • 是的,这在我的 web.config 中。我应该完全删除它并依赖归因吗?谢谢。我会试试的。
    猜你喜欢
    • 2021-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-11
    • 2020-08-04
    • 1970-01-01
    • 2020-04-12
    • 2020-03-09
    相关资源
    最近更新 更多