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?