在即将到来的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); } } }