使用不带OWIN身份验证中间件的WebAPI 2 [英] Use WebAPI 2 without OWIN authentication middleware

查看:74
本文介绍了使用不带OWIN身份验证中间件的WebAPI 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用ASP.NET WebAPI 2,但要使用自己的身份验证机制.我试图删除VS 2013中SPA模板以及常规WebAPI模板随附的所有代码.如果我从项目中删除了所有与auth相关的代码,并且没有在它的Startup.Auth中配置OWIN,我总是会收到一条错误消息,那就是未设置OWIN中间件身份验证,并且我无法执行任何控制器的操作.

I would like to use ASP.NET WebAPI 2, but with my own authentication mechanism. I have tried to remove all the code that comes with SPA template in VS 2013, as well as normal WebAPI template. If I remove all auth-related code from the project and don't configure OWIN in it's Startup.Auth, I always get an error, that OWIN middleware authentication is not setup and I can't get to any controller's action.

绕过OWIN主机.dll的问题(包括配置要求),用自己的代码在WebAPI 2中实现基于令牌的身份验证的正确方法是什么?

What is the correct way to implement a token based authentication in WebAPI 2 with own code, bypassing what's aready is in OWIN host .dll's, including it's requirements of configuration?

推荐答案

您可以使用空白的Asp.Net模板并将Web Api 2添加为nuget程序包,或从其他入门模板中删除未使用的内容.

You can use the blank Asp.Net template and add Web Api 2 as nuget packages, or remove unused stuff from the other starter templates.

这篇关于使用不带OWIN身份验证中间件的WebAPI 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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