2

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.

3
  • 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 ;) Commented 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. Commented Sep 14, 2015 at 7:44
  • 1
    You 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/… Commented Sep 14, 2015 at 8:25

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.