Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Asp.NET MVC Core Authentication?

$
0
0

I'm attempting to set a login system on an asp.net mvc core 1.0 (previously mvc6) that does some custom stuff. In the past I've always set a value in the FormsAuthentication cookie like this on login...

FormsAuthentication.SetAuthCookie(session_id, true);

And then picked out the value out on the request using OnAuthorization in the mvc controller class

protected override void OnAuthorization(AuthorizationContext filterContext)
{
    int session_id = 0;
    if (int.TryParse(User.Identity.Name, out session_id))
    {
        // ... code to lookup user/etc removed for brevity ...
        HttpContext.User = new Principal(user.FullName, "");
    }
}

It appears OnAuthorization is not present any more, and I'm unsure if forms authentication is there either.

How can we do something similar in the new asp.net mvc core stuff?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>