【发布时间】:2012-10-30 05:04:23
【问题描述】:
我有一个 WebApi 项目,我正在尝试向它添加一个区域。
将新区域添加到 webapi 项目与 mvc4 应用程序时,是否需要做一些不同的事情?
我有一个简单的区域注册,比如
public class MobileAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Mobile";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Mobile_default",
"Mobile/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
}
类似的控制器
public class BusinessDetailsController : BaseController
{
public string Index()
{
return "hello world";
}
public HttpResponseMessage Get()
{
var data = new List<string> {"Store 1", "Store 2", "Store 3"};
return Request.CreateResponse(HttpStatusCode.OK, data);
}
}
但是我永远无法访问 api。我是在做一些愚蠢的事情,还是需要对 webapi 进行额外的操作?
【问题讨论】:
标签: c#-4.0 asp.net-mvc-4 asp.net-web-api