简体   繁体   English

在具有Web API控制器的MVC5项目中使用Cookie身份验证

[英]Use cookie authentication in mvc5 project with web api controller

We have an application in production built in mvc5 with cookie authentication. 我们在具有cookie身份验证的mvc5内置的生产环境中有一个应用程序。 We added a component to this project that uses web api controller. 我们向使用Web API控制器的项目添加了一个组件。 When a logged in user tries to access the part of the system that uses web api the controller is asking them to sign in again. 当登录的用户尝试访问使用Web API的系统部分时,控制器会要求他们再次登录。 Is there a way to make web api use the same cookie authentication as the mvc controllers? 有没有一种方法可以使Web api使用与mvc控制器相同的cookie身份验证?

You cannot authenticate WebApi by the use of cookies. 您不能通过使用cookie来验证WebApi。 If you want to a secured WebApi you should implement your access token generation. 如果要使用安全的WebApi,则应实现访问令牌的生成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM