向ASP.NET WebApi 2.2添加身份验证 [英] Add Authentication to ASP.NET WebApi 2.2

查看:197
本文介绍了向ASP.NET WebApi 2.2添加身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个WebApi 2.2项目(来自一个空的ASP.NET新项目)以证明一些实现概念,现在我想向其中添加身份验证.

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应用程序上添加身份验证的唯一方法是使用一种(以我为例,VS 2013)模板.

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 2.2应用程序的可靠方法?

Is there a sure-fire way of adding Authentication to an already existing WebApi 2.2 app?

我只会使用不记名令牌,如果这会影响我可能收到的任何答案.

I will only want to use bearer tokens, if that makes a difference to any answers I may receive.

推荐答案

是的,您可以从头开始添加承载身份验证,我不是VS 2013模板的忠实拥护者,因为它们混在cookie和令牌身份验证之间.您可以检查我的

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. You can check my detailed blog post on how to add bearer tokens only to new or existing Web API project. Let me know if you need further help.

这篇关于向ASP.NET WebApi 2.2添加身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆