Is possible to use cookie based authentication wit

2020-06-12 02:47发布

问题:

I want to create the web application which will be based on angularjs frontend and ASP.NET Web API. I need create the secure api but I can't use the token based authentication on the company's server where will be implemented this web application.

Is possible use the cookie based authentication for SPA and ASP.NET Web API?

How can I configure the cookie based authentication on the ASP.NET project for this scenario where I have the SPA and Web API?

回答1:

The TokenBased Authentication is currently used in SPA based on BackEnd API applications is to overcome the limitation of cookiebased authentication But since you have decided to go with it then you can use OWIN cookieAuthentication middleware which will do the needful. Here's an article showing how to configure the OWIN cookie authentication middleware in Asp.net project(No matter if it's WebApi or MVC application).