【发布时间】:2013-06-14 02:30:34
【问题描述】:
我有一个正在尝试测试的 WebApi 项目。我有一个控制器 -
public class UserController : ApiController
{
public string Get()
{
return "foo";
}
}
我需要测试路由,我正在尝试使用WebApiContrib.Testing 包。
现在,我的问题是,在注册路由时,我使用 GlobalConfiguration.Configuration.Routes,它的类型为 HttpRouteCollection。
在我的测试中,我可以访问RouteTable.Routes,但这是RouteCollection 类型。
因此,由于这种类型不兼容,我无法在我的测试中注册 WebApi 路由。
以前有人遇到过这个问题吗?我有什么明显的遗漏吗?
【问题讨论】:
标签: c# asp.net-web-api asp.net-routing web-api-contrib