在MVC 4中使用ASP.Net Identity

前端之家收集整理的这篇文章主要介绍了在MVC 4中使用ASP.Net Identity前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在即将到来的ASP.net: http://blogs.msdn.com/b/webdev/archive/2013/06/27/introducing-asp-net-identity-membership-system-for-asp-net-applications.aspx版本中,我一直在阅读有关新的auth的内容

我在Visual Studio 2012中创建了一个新的ASP.net MVC 4项目,我想使用新的auth位,如果可以的话.这可能吗?

我正在阅读代码,并试图围绕这个新的API.但与此同时,要走什么步骤呢?

解决方法

应该是可以的,首先你基本上要安装3个包:
Microsoft.AspNet.Identity.Core
Microsoft.AspNet.Identity.EntityFramework
Microsoft.AspNet.Identity.Owin

然后,您还需要拉入相关的Owin包:

Owin
Microsoft.Owin
Microsoft.Owin.Security
Microsoft.Owin.Security.Cookies
Microsoft.Owin.Host.SystemWeb

然后你需要连接这样的东西:

using Microsoft.Owin;
using Owin;

[assembly: OwinStartupAttribute(typeof(WebApplication19.Startup))]
namespace WebApplication19
{
    public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
                // Enable the application to use a cookie to store information for the signed in user
                app.UseCookieAuthentication(new CookieAuthenticationOptions
                {
                    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,LoginPath = new PathString("/Account/Login")
                });
                // Use a cookie to temporarily store information about a user logging in with a third party login provider
                app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
        }
    }
}

您还必须删除/关闭您的应用程序中的所有旧会员/表单认证,并切换到使用新的身份API.

原文链接:https://www.f2er.com/aspnet/250319.html

猜你在找的asp.Net相关文章