将Route属性添加到ApiController

时间:2015-04-29 12:14:32

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

我正在使用.NET Framework 4.0和C#开发ASP.NET Web Api应用程序。

我有这个:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace MyProject.Web.Api.Controllers
{
    public class UserADController : ApiController
    {
        [HttpGet]
        [Route("api/UserAD/GetAllUsers")]
        public HttpResponseMessage GetAllUsers()
        {
            HttpResponseMessage response = null;


            return response;
        }

    }
}

但是System.Web.Http.dll上没有RouteAttribute(这是\packages\Microsoft.AspNet.WebApi.Core.4.0.30506.0\lib\net40\System.Web.Http.dll)。

属性路由在ASP.NET MVC 5或更高版本以及ASP.NET Web API 2中是本机的。

此ASP.NET版本中此Route属性的等效项是什么?

0 个答案:

没有答案
相关问题