【发布时间】:2015-08-06 13:18:56
【问题描述】:
我有两个 Web API 项目,我有一个 MarketController,我需要扩展 Api 控制器,所以我做到了。
我创建了一个BaseController 类并继承自ApiController,如下所示:
public class BaseController:ApiController { }
到目前为止一切顺利,一切正常:
public class MarketController : BaseController
{
public MarketController() : base()
{
}
// GET api/<controller>
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
}
但我想在另一个名为 BLL 的类库中执行此操作,因此我将 BaseController 类移至 BLL 类库并在 Web API 项目中引用它。
当我这样做时,api 停止工作。
回复是:
{
"Message": "No HTTP resource was found that matches the request URI someurl/api/market.",
"MessageDetail": "No type was found that matches the controller named 'market'."
}
【问题讨论】:
-
嘿,在下面查看我的答案。
标签: c# asp.net-web-api controller