gpt4 book ai didi

时间:2019-03-08 标签:c#webapihttpgetattribute

转载 作者:太空狗 更新时间:2023-10-30 00:42:02 26 4
gpt4 key购买 nike

我正在学习本教程:

http://www.asp.net/web-api/overview/web-api-routing-and-actions/create-a-rest-api-with-attribute-routing

并查看“获取图书详细信息”部分。

我看到这段代码:

[HttpGet("api/books/{id}/details")]
public BookDetailDto GetBookDetail(int id)
{
}

但是我得到的错误是

HttpGet has 0 parameters but is invoked with 1 argument

(我在 ASP .net 4.0 WebAPI 上)

指定路线的/details 部分的新方法是什么?


我的核心:

  <package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" targetFramework="net40" />
<package id="Microsoft.AspNet.Mvc.FixedDisplayModes" version="1.0.0" targetFramework="net40" />
<package id="Microsoft.AspNet.Providers.Core" version="1.2" targetFramework="net40" />
<package id="Microsoft.AspNet.Providers.LocalDB" version="1.1" targetFramework="net40" />
<package id="Microsoft.AspNet.Razor" version="2.0.20715.0" targetFramework="net40" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.0.0" targetFramework="net40" />
<package id="Microsoft.AspNet.WebApi" version="4.0.20710.0" targetFramework="net40" />
<package id="Microsoft.AspNet.WebApi.Client" version="4.0.20710.0" targetFramework="net40" />
<package id="Microsoft.AspNet.WebApi.Core" version="4.0.20710.0" targetFramework="net40" />
<package id="Microsoft.AspNet.WebApi.HelpPage" version="4.0.0" targetFramework="net40" />
<package id="Microsoft.AspNet.WebApi.OData" version="4.0.0" targetFramework="net40" />
<package id="Microsoft.AspNet.WebApi.Tracing" version="4.0.0" targetFramework="net40" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="4.0.20710.0" targetFramework="net40" />
<package id="Microsoft.AspNet.WebPages" version="2.0.20710.0" targetFramework="net40" />

正在尝试升级到 WEBAPI 的测试版

update-Package : Could not install package 'Microsoft.AspNet.WebApi.Client 5.0.0-beta2'. 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. For more information, contact the package author.

Update-Package : Updating 'Microsoft.AspNet.Mvc 4.0.30506.0' to 'Microsoft.AspNet.Mvc 5.0.0-beta2' failed. Unable to find a version of 'Microsoft.AspNet.Mvc.FixedDisplayModes' that is compatible with 'Microsoft.AspNet.Mvc 5.0.0-beta2'.
Update-Package : Updating 'Microsoft.AspNet.Mvc 4.0.30506.0' to 'Microsoft.AspNet.Mvc 5.0.0-beta2' failed. Unable to find a version of 'Microsoft.AspNet.Mvc.FixedDisplayModes' that is compatible with 'Microsoft.AspNet.Mvc 5.0.0-beta2'.

通过重定向到 4.5 并删除 FixedDisplayModes 包修复了这些问题

最佳答案

您的包列表显示您正在使用 ASP.NET Web API 1。属性路由 支持在 ASP.NET Web API 2 中可用,它是 Visual Studio 2013 Preview 的一部分。目前处于测试版。如果你想玩它,你可以通过三种方式来做到这一点:

  • 将包管理器窗口顶部的下拉列表值从“仅稳定版”更改为“包括预发布版”并将您的包升级到 Microsoft ASP.NET Web API 5.0.0-beta2(有时Microsoft ASP.NET MVC Fixed DisplayModes 包正在阻止更新,因此您可以先尝试将其删除)
  • 将您的项目切换到 ASP.NET Web API Nightly Builds
  • Download并安装带有适当引用和新模板的 Visual Studio 2013 Preview。

关于时间:2019-03-08 标签:c#webapihttpgetattribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17673346/

26 4 0