问题描述
可能重复:结果
Cross使用ASP.NET的Web API 平台身份验证
我要创建一个新的Visual Studio 11 Beta测试阶段的asp.net网页API。此Web API将需要由不同的网站,桌面应用程序和移动应用进行访问。什么是执行身份验证/授权我的网页API的最好方式。我需要确保所有调用API的应用程序进行身份验证。有一个简单的方式与新的Web API来做到这一点?
I want to create an asp.net web api with the new visual studio 11 beta. This web api will need to be accessed by different websites, desktop apps, and mobile apps. What is the best way to perform authentication/authorization for my web api. I need to make sure that all the apps calling the api are authenticated. Is there an easy way to do this with the new web api?
推荐答案
我用一个消息处理程序来检查请求的AUTH头做了它,并设置标识所以[授权]属性可以做到这一点的的事情。
I've done it by using a message handler to check for the auth header in the request and set up the identity so the [Authorize] attribute can do it's thing.
我写了一个关于这个问题的。
I've written a blog post on the subject..
这篇关于用的ASP.NET Web API认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!