Using ASP.Net Identity in MVC 4

11,789

It should be doable, first you basically want to install the 3 packages:

Microsoft.AspNet.Identity.Core
Microsoft.AspNet.Identity.EntityFramework
Microsoft.AspNet.Identity.Owin

You would then need to pull in the associated Owin packages as well:

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

And you would then need to hookup Owin with something like this:

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);
        }
    }
}

You will also have to remove/turn off all of the old membership/forms auth in your app, and switch to using the new identity APIs.

Share:
11,789

Related videos on Youtube

MsBao
Author by

MsBao

Updated on September 16, 2022

Comments