我遇到了一個讓我發瘋的問題。MVC 4 Web API區域404錯誤
我有一個MVC 4 WebAPI應用程序,有幾個區域定義。
我的工作區發送控制器(SendController.cs)的定義,像這樣:
namespace TargetAPI.Areas.Jobs.Controllers
{
public class SendController : ApiController
{
[HttpPost]
public HttpResponseMessage Index(SendRequest req)
{
try
{
//blah blah
}
catch (Exception ex)
{
//blah blah
}
}
}
}
我的工作區登記(JobsAreaRegistration.cs)就像是這樣定義的:
namespace TargetAPI.Areas.Jobs
{
public class JobsAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Jobs";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Jobs_long",
"Jobs/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional },
new[] { "TargetAPI.Areas.Jobs.Controllers" }
);
}
}
}
我RouteConfig。 cs說:
namespace TargetAPI
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home",
action = "Index", id= UrlParameter.Optional },
namespaces: new string[] { "TargetAPI.Controllers" }
);
}
}
}
當我運行路由調試器時,我得到: My Route Debug http://imagestore2.boomerang.com/img/temp/routedebug.jpg
但是當我嘗試張貼到URL「喬布斯/發送」我得到:
的路徑控制器「/工作/發送」未找到或沒有實現一個IController。
我試過這麼多的迭代和組合我的頭旋轉。有任何想法嗎?
謝謝!
哇,多麼不幸。一天的谷歌搜索,並最終找到了這個答案。謝謝。 – Derrick