I have various AngularJS single page applications running in a single ASP .net MVC project. In one of my AngularJS SPA's I need to create a login page which would show then show another page of information when successfully logged in. The username and passwords are stored in a database. I am very new to ASP .net and would like some advice on the best way to (using my angular form) login and have some kind of session cookie so the user remains logged in for the duration of their session.
-
You should really come up with a question(provide what you have done or where you have any error), otherwise you will get negative feedback ;)Alexa Adrian– Alexa Adrian2015-09-14 07:09:36 +00:00Commented Sep 14, 2015 at 7:09
-
You can just use the built in Mvc login and serve the spa in the authorize protected controller that you redirect to on successful login. Is that what you want to do? It's unclear from your question. If you want to secure an API you need to issue a bearer token which is slightly different.hally9k– hally9k2015-09-14 07:44:09 +00:00Commented Sep 14, 2015 at 7:44
-
1You can go for inbuilt mvc authentication of mvc or you can create custom form authentication in asp.net mvc for managing users of your application. sergiowilson.net/Dev-News/entryid/20/…Ankit K– Ankit K2015-09-14 08:25:11 +00:00Commented Sep 14, 2015 at 8:25
Add a comment
|
1 Answer
If you build SPA you with high probability use WebAPI. Reccomended way to authenticate API user is slightly different than usual cookie authentification.
To see how it works create a new project. If you have last VS2015 go to file -> New project -> ASP.NET Web Application -> Web API (Authentification: Individual UserAccounts).
If you just return Json(someData) in your MVC contollers and already have authentification it should work fine on tradition cookie authentification.