c# - "The type or namespace name ' 使用 ' could not be found"路由 "attribute routing"

标签 c# asp.net asp.net-mvc-4 asp.net-web-api url-routing

只是试图将一些代码从一个工作项目拼接到另一个。 “from”项目使用“属性路由”,您可以在 Web API Controller 模块中嵌入 [Route(…)] 指令来指示应该将哪个 HTTP 消息路由到哪个服务例程。

在“from”项目中工作正常,但在“to”项目中我收到构建错误“找不到类型或 namespace 名称‘Route’(是否缺少 using 指令或程序集引用?) "

我已经尝试将“from”项目中的所有using 语句基本上复制到“to”项目中,但这没有明显效果。没有任何 MS 文档表明需要 NuGet 包(甚至是 using 语句)。这两个项目都应该是 ASP.NET MVC 4。

(是的,我用 config.MapHttpAttributeRoutes(); 语句更新了 WebApiConfig.cs。)

有什么想法吗??

最佳答案

Vedran Mandić 的这条评论为我解决了这个问题。我在这里重新发布它,因为我认为它应该是答案(或至少是答案)。

I did an 'Update-Package Microsoft.AspNet.WebApi.WebHost -reinstall' and it worked. Funny this happens after getting the latest version on different PCs from TFS. I guess this happens because of nuget packages not working properly with the versioning system

关于c# - "The type or namespace name ' 使用 ' could not be found"路由 "attribute routing",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24419324/

相关文章:

c# - 尝试在 MVC4 和 Razor 上使用两个布局页面

c# - 在 ASP.NET MVC4 中——我需要编辑一条记录并向其添加许多(1 到许多)子记录(在顶级记录的编辑模式下)

c# - GridView中LinkBut​​ton的行索引

c# - 第一次反序列化比后续反序列化花费的时间要长得多

javascript - 当函数位于外部 javascript 文件中时 onclick 事件不起作用

c# - 分层架构。正确地做

c# - PartialView 不渲染在 ajax post 调用上更新的模型

c# - Linq/删除空格返回实际值 'system.char'

c# - Web API 响应 xml 语言

asp.net - UpdatePanel 没有名为 'TextBox' 的公共(public)属性。