user3407039
user3407039

Reputation: 1335

AngularJS with web API authentication

I have recently started learning AngularJS and I'm trying to create a simple login system. Some of the methods for creating and storing a cookie for authorisation looked a lot more complicated than the .net approach I was use to so my first thought was to keep using that method of authentication by doing a call to the API and keeping the angular UI side free of all that.

This option was suggested in this post here -

How to handle authentication in Angular JS application

However when I try to implement this it authenticates fine, but it does not save this cookie. If I access the API again and try anything referencing the cookie like,

FormsAuthentication.GetAuthCookie(userName, createPersistentCookie);

It will just say that there is nothing there.

Is there a simple way of retaining this cookie in the API that I am not using?

Upvotes: 3

Views: 1101

Answers (1)

Nicholas J. Markkula
Nicholas J. Markkula

Reputation: 1572

Here is how you can do it, this will also let you include custom information with the auth cookie.

https://stackoverflow.com/a/10524305/1121845

Upvotes: 1

Related Questions