简体   繁体   English

在网站项目中找不到System.Net.Http

[英]Unable to find System.Net.Http in web site project

I am working with a web site project within Visual Studio 2015. I usually work with web applications so this type of project is new to me. 我正在Visual Studio 2015中处理一个网站项目。我通常会处理Web应用程序,因此这种类型的项目对我来说是新的。

This application consist of ASP.NET pages (aspx and .cs code behind files). 该应用程序由ASP.NET页(文件后的ASPX和.CS代码)组成。 I wanted to add some code to one of the code behind files that would make use of the HttpClient library, however I cannot seem to add a reference to System.Net.Http. 我想在使用HttpClient库的文件后面的代码之一中添加一些代码,但是我似乎无法添加对System.Net.Http的引用。 It is not present in the references. 它在参考文献中不存在。 I do see that the project is targeting .NET 4.0. 我确实看到该项目针对.NET 4.0。 Could that be the issue? 这可能是问题吗?

在此处输入图片说明

You can use NuGet to install this assembly. 您可以使用NuGet来安装此程序集。 Just run it in the Package Manager Console(View -> Other Windows -> Package Manager Console): 只需在Package Manager控制台中运行它(查看->其他Windows-> Package Manager控制台):

Install-Package System.Net.Http

UPDATE UPDATE

If you use .NET 4.0 then you can't install the latest version of System.Net.Http because it doesn't compatible with that framework. 如果使用.NET 4.0,则无法安装最新版本的System.Net.Http,因为它与该框架不兼容。 You have to use: 您必须使用:

Install-Package Microsoft.Net.Http -Version 2.0.20710

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

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