Ron*_*rby 13 asp.net asp.net-identity
我一直在阅读即将推出的ASP.net版本中新的auth内容:http://blogs.msdn.com/b/webdev/archive/2013/06/27/introducing-asp-net-identity-membership -system换ASP净applications.aspx
我正在visual studio 2012中创建一个新的ASP.net MVC 4项目,如果可以,我想使用新的auth位.这可能吗?
我正在阅读代码并尝试围绕这个新的API.但与此同时,要采取哪些措施?
Hao*_*ung 20
它应该是可行的,首先你基本上想要安装3个包:
Microsoft.AspNet.Identity.Core
Microsoft.AspNet.Identity.EntityFramework
Microsoft.AspNet.Identity.Owin
Run Code Online (Sandbox Code Playgroud)
然后,您还需要引入相关的Owin包:
Owin
Microsoft.Owin
Microsoft.Owin.Security
Microsoft.Owin.Security.Cookies
Microsoft.Owin.Host.SystemWeb
Run Code Online (Sandbox Code Playgroud)
然后你需要用这样的东西连接Owin:
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);
}
}
}
Run Code Online (Sandbox Code Playgroud)
您还必须删除/关闭应用中的所有旧成员资格/表单身份验证,然后切换到使用新的身份API.
| 归档时间: |
|
| 查看次数: |
11496 次 |
| 最近记录: |