System.Net.Http不见了? [英] System.Net.Http missing?

查看:2539
本文介绍了System.Net.Http不见了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行Test.aspx文件中:

I am trying to run Test.aspx:

<%@ Page language="c#" EnableViewState="true" ContentType="text/html" Async="true" %>

<script language="C#" runat="server">

    void Page_Load(Object Src, EventArgs E )
    {
        RegisterAsyncTask(new PageAsyncTask(BindData));
    }

    private async System.Threading.Tasks.Task BindData()
    {
        Response.Write("Hello?<br /><br />");

        using (System.Net.Http.HttpClient httpClient = new System.Net.Http.HttpClient())
        {
            Response.Write(await httpClient.GetStringAsync("http://www.google.com"));
        }

        Response.Write("<br /><br />Is this thing on?<br /><br />");
    }

</script>

和得到这个错误:

Test.aspx(14): error CS0234: The type or namespace name 'Http' does not exist in the namespace 'System.Net' (are you missing an assembly reference?)

该System.Net.Http.dll组件在

The System.Net.Http.dll assembly is in

C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies

和在IIS管理器的基本设置应用程序池是ASP.NET 4.0版(集成)。有没有人碰到这个?

and in IIS Manager the Basic Settings' Application Pool is ASP.NET v4.0 (Integrated). Has anyone run into this?

更新:我安装了.NET 4.5.2,并添加以下的web.config

UPDATE: I installed .Net 4.5.2 and added the following web.config

<configuration>
  <system.web>
    <httpRuntime targetFramework="4.5" />
   <compilation>
      <assemblies>
         <add assembly="System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
      </assemblies>
   </compilation>
  </system.web>

</configuration>

和它的工作。

推荐答案

要解决此我不得不添加

<add assembly="System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

 <httpRuntime targetFramework="4.5.2" />

要在web.config

to the web.config

这篇关于System.Net.Http不见了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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