找不到类型或命名空间名称“ResponseType”。 System.Web.HTTP中不存在

时间:2014-05-15 13:42:40

标签: c# asp.net-web-api asp.net-web-api2

我正在尝试创建一个webapi。我收到了上述错误。我试过安装最新最好的。见下文。但它没有ResponseType的属性/属性等。我列出了System.Web.Http.Description。任何帮助将不胜感激。

 <Reference Include="System.Web.Http, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.0.0\lib\net45\System.Web.Http.dll</HintPath>
    </Reference>

和SubmissionController:

using System.Web.Http.Description;

[EnableCors(origins: "", headers: "", methods: "*")]
public class SubmissionController : ApiController 
{ 
    [Queryable] 
    [ResponseType(typeof(Submission))] 
    <!--error here --> 
    public IQueryable<Submission> Get(ODataQueryOptions opts) 
    { 
        ----code is in here---- 
    }
}

这是我的package.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="CommonServiceLocator" version="1.0" targetFramework="net45" />
  <package id="elmah" version="1.2.2" targetFramework="net45" />
  <package id="elmah.corelibrary" version="1.2.2" targetFramework="net45" />
  <package id="Elmah.MVC" version="2.1.1" targetFramework="net45" />
  <package id="EntityFramework" version="6.1.0" targetFramework="net45" />
  <package id="Microsoft.AspNet.Cors" version="5.1.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi" version="5.1.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.1.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.1.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Cors" version="5.1.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.OData" version="5.1.2" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.1.2" targetFramework="net45" />
  <package id="Microsoft.Data.Edm" version="5.6.1" targetFramework="net45" />
  <package id="Microsoft.Data.OData" version="5.6.1" targetFramework="net45" />
  <package id="Moq" version="4.2.1402.2112" targetFramework="net45" />
  <package id="Newtonsoft.Json" version="6.0.3" targetFramework="net45" />
  <package id="RhinoMocks" version="3.6.1" targetFramework="net45" />
  <package id="structuremap" version="3.0.3.116" targetFramework="net45" />
  <package id="STTI.DataService.Library.Server" version="1.1.1.1" targetFramework="net45" />
  <package id="STTI.Elmah.Avectra" version="1.0.0" targetFramework="net45" />
  <package id="STTI.Elmah.Core" version="1.0.0" targetFramework="net45" />
  <package id="STTI.netForum.Dependencies" version="1.1.1.1" targetFramework="net45" />
  <package id="STTI.Survey.API.Library" version="1.1.1.6-Development" targetFramework="net45" />
  <package id="System.Spatial" version="5.6.1" targetFramework="net45" />
  <package id="TaskHelpers.Sources" version="0.1" targetFramework="net45" />
  <package id="WebApiContrib" version="0.9.14.0" targetFramework="net45" />
  <package id="WebApiContrib.Formatting.Jsonp" version="3.0.0.0" targetFramework="net45" />
  <package id="WebApiContrib.IoC.StructureMap" version="0.9.5.0" targetFramework="net45" />
  <package id="WebApiContrib.Testing" version="0.7.18.0" targetFramework="net45" />
</packages>

1 个答案:

答案 0 :(得分:1)

reinstall command and the dangers of...

update-package -reinstall

......但它对我有用。