The text of this article is not in this database — only its details are. Read it on the old site: Token Based Authentication Using ASP.NET Web API in AngularJS
27 Comments
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.

Moises OlmoPosted Oct 16, 2018, 9:47 AM
Would you can tell me how can i implement CRUD operations with this
Tridip BhattacharjeePosted Apr 11, 2018, 4:25 AM
Please tell me what the below line will be doing.......config(['$httpProvider', function ($httpProvider) { $httpProvider.interceptors.push(function ($q, $rootScope, $window, $location) { return { request: function (config) { return config; }, requestError: function (rejection) { return $q.reject(rejection); }, response: function (response) { if (response.status == "401") { $location.path('/login'); } //the same response/modified/or a new one need to be returned. return response; }, responseError: function (rejection) { if (rejection.status == "401") { $location.path('/login'); } return $q.reject(rejection); } }; });
Tridip BhattacharjeePosted Apr 11, 2018, 4:23 AM
Nice article but like title of article there is no web api code in this post.
Rupesh prasadPosted Aug 16, 2016, 4:21 PM
Can you tell me how do i get this token based auth work with ASP.NET web forms. I mean if user is not logged in then redirect to login page and all, most importantly how do i check if user is logged in or not?? For federation authentication we simple check page.isuerAuthenticated which gets set by IuserPrincipal. For this how is it gonna work?
kalu singh raoPosted Jul 4, 2016, 2:03 AM
Nice...
Debasis SahaPosted May 26, 2016, 8:12 AM
Nice sharing..
Claude JoasilPosted Feb 25, 2016, 11:27 AM
The headers were never set for the request. in this.validateRequest Make sure you add this.setHeader($http); before $http.get(url).then(function () {.... So between line 37 and 38 in authenticationService.js
jasmin patelPosted Feb 21, 2016, 1:36 AM
another problem is after login try to refresh page welcome message ,my info,logout link hide
jasmin patelPosted Feb 21, 2016, 1:16 AM
can u solve that problem and upload sample project again?
jasmin patelPosted Feb 21, 2016, 1:04 AM
Nice example but after login page redirect to next page and then validate request function called this.validateRequest = function () { debugger; var url = serviceBase + 'api/home'; var deferred = $q.defer(); $http.get(url).then(function () { deferred.resolve(null); }, function (error) { deferred.reject(error); }); return deferred.promise; } and got this error when get request to api/home --> GET http://localhost:49707/api/home 401 (Unauthorized)
Sabyasachi MishraPosted Dec 19, 2015, 7:19 AM
Good one
Marco TugnoliPosted Nov 16, 2015, 3:48 AM
Nice work, but ... 1) after logged, "next" page is not available 2) on logging if I debug this error occour : "GET http://localhost:49707/api/home 401 (Unauthorized)", but i'm authorized !! 3) after logout have to go to login page 4) will be nice if showing a "wait icon" on loading
Ajeet MishraPosted Sep 26, 2015, 2:16 AM
nice
Saineshwar BageriPosted Sep 25, 2015, 8:33 AM
Nice one
Sibeesh VenuPosted Sep 25, 2015, 3:40 AM
Nice Share :)
Pankaj Kumar ChoudharyPosted Sep 25, 2015, 3:34 AM
Great Article Sir..........
Santhakumar MunuswamyPosted Sep 25, 2015, 2:38 AM
Good work
Ankit BansalPosted Sep 25, 2015, 1:07 AM
nice...thanks for sharing
Harshad PansuriyaPosted Sep 25, 2015, 12:48 AM
Nice Share
Shridhar SharmaPosted Sep 24, 2015, 1:22 PM
nice share :)
Rajeesh MenothPosted Sep 24, 2015, 12:47 PM
Nice One...
Nilesh JadavPosted Sep 24, 2015, 11:51 AM
Great work sir !!