1
我正在嘗試創建一個webapi。我得到了上述錯誤。我試圖安裝最新最好的。見下文。但它沒有ResponseType的屬性/屬性等。我列出了System.Web.Http.Description。任何幫助,將不勝感激。無法找到類型或名稱空間名稱'ResponseType'。在System.Web.HTTP中不存在
<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>
'ApiDescription'類沒有'ResponseType'屬性。 [見MSDN](http://msdn.microsoft.com/en-us/library/system.web.http.description.apidescription(v = vs.118).aspx)。你是不是指'ResponseDescription'? – mason
你是否試圖用'ResponseTypeAttribute'來標記你的控制器方法?另外,你可以發佈你的packages.config文件和web.config文件以及一些代碼嗎?這會幫助我們一點點。 –
我認爲你必須提供一些代碼給我們,以幫助你。 '[ResponseType]'屬性是'System.Web.Http.Description'命名空間的一部分。如果包含該名稱空間並且該屬性被正確定義,則該異常必須消失。 – HuorSwords