Thursday, September 1, 2016

Get current user id in MVC

Getting current users id has been made very simple with Microsoft.AspNet.Identity.Core nuget package,

First off install the nuget package
Install-Package Microsoft.AspNet.Identity.Core


Now add this using directive in class
using Microsoft.AspNet.Identity;

And finally fetch the current users id by
HttpContext.Current.User.Identity.GetUserId();

No comments:

SSL Error - The connection for this site is not secure

 After cloning a git repo of dot net framework website and trying to run it all I could see was this error Turns out the fix was to simply e...