网页API路由属性未找到 [英] web api Route attribute not found

查看:173
本文介绍了网页API路由属性未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要实现我的Web服务,它可通过定义路径的方法。
所以我使用了路线属性是这样的:

I need to implement a Method in my web service, which is available by a defined route. So I used the Route attribute like this:

    [Route ("api/Patient")]
    public Patient CreateNewPatientInGroup(int gid, Patient item)
    {
        //Do stuff
    }

但VS2013说,命名空间路线不能被发现。

But VS2013 says that the namespace "Route" can't be found.

我想这可以通过安装的NuGet包来解决。

I guess this can be solved by installing a nuget package.

有人能帮忙吗?

推荐答案

属性路由原产于ASP.NET MVC 5或更高版本,和ASP.NET Web API 2。
检查你的MVC版本,它应该是4以上。

Attribute Routing is native in ASP.NET MVC 5, or later, and ASP.NET Web API 2. check your MVC version it should be above the 4.

这篇关于网页API路由属性未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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