[英]How to debug MVC3/WebAPI routing 404 error?
My WebAPI route is defined as follows: 我的WebAPI路由定义如下:
config.Routes.MapHttpRoute(
name: "BuildModels",
routeTemplate: "api/build/models/{productLine}/{language}",
defaults: new { controller = "Build", action = "GetModels" }
);
Controller: 控制器:
public class BuildController : ApiController
{
public async Task<HttpResponseMessage> GetModels(string productLine, string language)
{
// Omitted for brevity, I don't feel it's pertinent
// but if you disagree I will fill this in.
// Nothing has changed in here and it worked before.
return await ...;
}
}
/api/build/models/x/en / API /编译/模型/ X / EN
[HttpException]: The controller for path '/api/build/models/x/en' was not found or does not implement IController.
at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType)
at System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName)
at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
/api/build/models/x/ / API /编译/模型/ X /
{"Message":"The arguments value is not valid : {language}"}
All of my routes are working except the ones on this single controller, which were working before. 除了以前在该单个控制器上运行的路由外,我所有的路由都在工作。 I obviously changed something, just can't figure out what.
我显然改变了一些东西,只是不知道是什么。
Have you tried activating custom errors? 您是否尝试过激活自定义错误?
<customErrors mode="On" defaultRedirect="/customerrors/500.aspx">
<error statusCode="404" redirect="/customerrors/404.html" />
<error statusCode="403" redirect="/customerrors/403.html" />
</customErrors>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.