在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 @R_976_4045@ion for the signed in user
                app.UseCookieAuthentication(new CookieAuthenticationoptions
                {
                    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,LoginPath = new PathString("/Account/Login")
                });
                // Use a cookie to temporarily store @R_976_4045@ion about a user logging in with a third party login provider
                app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
        }
    }
}

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

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....