使用mvc 5设置特定的身份验证类型

时间:2015-11-27 13:14:28

标签: authentication asp.net-mvc-5 owin

ASP.NET默认使用外部登录提供程序部分页面,该页面设置为:

var loginProviders = Context.GetOwinContext().Authentication.GetExternalAuthenticationTypes();
                if (loginProviders.Count() == 0)
                {
                    <div>
                        <p>
                            There are no external authentication services configured. See <a href="http://go.microsoft.com/fwlink/?LinkId=403804">this article</a>
                            for details on setting up this ASP.NET application to support logging in via external services.
                        </p>
                    </div>
                }
                else
                {
                    using (Html.BeginForm("ExternalLogin", "Account", new { ReturnUrl = Model.ReturnUrl }))
                    {
                        @Html.AntiForgeryToken()
                        <div id="socialLoginList">
                            <p>
                                @foreach (AuthenticationDescription p in loginProviders)
                                {
                                    <button type="submit" class="btn btn-default" id="@p.AuthenticationType" name="provider" value="@p.AuthenticationType" title="Log in using your @p.Caption account">@p.AuthenticationType</button>
                                }
                            </p>
                        </div>
                    }
                }

如果我确切知道我要使用的身份验证类型,比如说facebook怎么办?我怎么设置它?

0 个答案:

没有答案