简体   繁体   English

将身份验证添加到ASP.NET WebApi 2.2

[英]Add Authentication to ASP.NET WebApi 2.2

I have created a WebApi 2.2 project (from an Empty New ASP.NET Project) to prove some implementation concepts and I now want to add Authentication to it. 我已经创建了一个WebApi 2.2项目(来自一个空的新ASP.NET项目)来证明一些实现概念,我现在想要为它添加身份验证。

I notice that the only way to add Authentication on a new WebApi app is to use one of the (VS 2013, in my case) Templates. 我注意到在新的WebApi应用程序上添加身份验证的唯一方法是使用其中一个(VS 2013,在我的情况下)模板。

Is there a sure-fire way of adding Authentication to an already existing WebApi 2.2 app? 是否有一种确定的方法可以将身份验证添加到现有的WebApi 2.2应用程序中?

I will only want to use bearer tokens, if that makes a difference to any answers I may receive. 我只想使用持票人代币,如果这对我可能收到的任何答案产生影响。

Yes you can add the bearer authentication from scratch, I'm not big fan of the VS 2013 templates because they mix between cookies and tokens authentication. 是的,你可以从头开始添加承载认证,我不是VS 2013模板的忠实粉丝,因为它们混合了cookie和令牌认证。 You can check my detailed blog post on how to add bearer tokens only to new or existing Web API project. 您可以查看我的详细博客文章 ,了解如何仅向新的或现有的Web API项目添加承载令牌。 Let me know if you need further help. 如果您需要进一步的帮助,请告诉我。

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

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