简体   繁体   English

使用ASP.NET Web API令牌对我的ASP.NET MVC应用程序进行身份验证

[英]use asp.net web api token to authenticate my asp.net mvc application

I have created a new web api project with individual user account authentication. 我已经使用个人用户帐户身份验证创建了一个新的Web api项目。

I followed this post and everything worked as expected 我关注了这篇文章,一切都按预期进行

http://www.asp.net/web-api/overview/security/individual-accounts-in-web-api http://www.asp.net/web-api/overview/security/individual-accounts-in-web-api

Now, I have a token end point localhost:54452/Token 现在,我有一个令牌端点localhost:54452 / Token

Lets, say I create new asp.net mvc application. 假设我创建了一个新的asp.net mvc应用程序。 I want to use this token end point for authentication. 我想将此令牌端点用于身份验证。 How do I tell my controllers to use this token end point? 如何告诉我的控制器使用此令牌端点? How do I tell my controllers to pass the bearer access token on each request or how does these two work together. 我如何告诉我的控制器在每个请求上传递承载访问令牌,或者这两个如何一起工作。

asp.net mvc and asp.net web api are two different projects with different port numbers asp.net mvc和asp.net Web API是两个具有不同端口号的不同项目

Thanks, 谢谢,

Syed 赛德

I would create a wrapper class that uses HttpClient to issue HTTP requests to the Web API. 我将创建一个使用HttpClient向Web API发出HTTP请求的包装器类。 Then use this wrapper class when you're communicating with the Web API. 与Web API通信时,请使用此包装器类。 It will then handle adding the token to the HTTP request header. 然后它将处理将令牌添加到HTTP请求标头中。

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

相关问题 通过调用外部ASP.NET Web Api服务对ASP.NET MVC Web应用程序中的用户进行身份验证 - Authenticate a user in an ASP.NET MVC web application by calling an external ASP.NET Web Api service 了解 ASP.NET 中的令牌生成/验证(MVC、Web API) - Understanding Token Generation/Validation in ASP.NET (MVC, web API) ASP.Net Web API - 从 ASP.NET MVC 项目生成不记名令牌 - ASP.Net Web API - Generate Bearer Token from ASP.NET MVC Project 现有ASP.NET Web API中的ASP.NET MVC 4 - ASP.NET MVC 4 in existing ASP.NET Web API ASP.NET Web API + ASP.NET MVC身份验证 - ASP.NET Web API + ASP.NET MVC Authentication 从我的asp.net mvc Web应用程序调用asp.net控制台应用程序 - Calling an asp.net console application from my asp.net mvc web application 如何从启用基于场的身份验证的ASP.NET应用程序或ASP.NET MVC对基于SharePoint声明的Web应用程序进行身份验证 - How to authenticate sharepoint claims based web application from farm based authentication enabled asp.net application or asp.net mvc Asp.net Web Api令牌身份验证 - Asp.net Web Api Token Authentication 验证ASP.NET Web API中的访问令牌 - Validating an access token in my ASP.NET Web API 如何使用两个asp.net web api的持票令牌 - How to use bearer token with two asp.net web api
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM