简体   繁体   English

将 System.Net.Http 安装到 .net framework 4.0 项目

[英]install System.Net.Http to .net framework 4.0 project

I need use AuthenticationHeaderValue for getting token我需要使用 AuthenticationHeaderValue 来获取令牌

var token = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.UTF8.GetBytes($"{username}:{password}")));

so I have to install System.Net.Http package but when I install it via package manager console it give that error what should I do?所以我必须安装 System.Net.Http 包,但是当我通过包管理器控制台安装它时,它会出现错误我该怎么办? what is AuthenticationHeaderValue alternative?什么是 AuthenticationHeaderValue 替代方案?

Could not install package 'System.Net.Http 4.0.0'.无法安装包“System.Net.Http 4.0.0”。 You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework.您正在尝试将此包安装到以“.NETFramework,Version=v4.0”为目标的项目中,但该包不包含任何与该框架兼容的程序集引用或内容文件。

安装与您的 .Net Framework 兼容的 System.Net.http 版本

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

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