Ty53ler February 2016

Getting Data From ASP.NET MVC Membership Provider With AngularJS

So I am using the built in ASP.NET MVC membership provider for the authorization of users in my web application. I added several fields such as first name, last name and customer number to the default fields that it comes with (email, password). I am able to register and log in users but now I want to get some of the information of the added fields for the user and use it in my AngularJS controller.

I have been working with learning AngularJS and have been successful with using the WebAPI to get and post data to the server but I am stumped on how I can get the information of the current user who is signed in to my application. I am assuming it is stored in a session token of some sort but I do not know how to access it and work with that information from an angular standpoint.

Any help is appreciated, I can provide whatever code is necessary but at this point I only have the basic built in code that asp.net uses to register and login users and my empty angular controller. Thanks.

Answers


Dave Bush February 2016

To get the current user from anywhere on the server side, use

HttpContext.Current.User.Identity.Name;

Post Status

Asked in February 2016
Viewed 3,037 times
Voted 6
Answered 1 times

Search




Leave an answer