MVC5资源无法找到,哪有错?

时间:2017-11-17 20:10:56

标签: c# asp.net-mvc

你可以帮我找到资源找不到错误,对于ActionResult创建和查看创建

每个其他控制器/视图都在工作,我无法找到这个错误。

这是我的RouteConfig:

public static class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.LowercaseUrls = true;
        routes.MapRoute("Default", "{controller}/{action}/{id}", new
        {
            controller = AutoParts.Domain.Settings.IntegrationType == "Try" ? "Search" : "Home",
            action = "Index",
            id = UrlParameter.Optional
        }).RouteHandler = new DashRouteHandler();
    }
}

这是DashRouteHandler:

public class DashRouteHandler : MvcRouteHandler
    {            
        protected override IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            var routeValues = requestContext.RouteData.Values;

            routeValues["action"] = routeValues["action"].UnDash();
            routeValues["controller"] = routeValues["controller"].UnDash();

            return base.GetHttpHandler(requestContext);
        }
    }

这是我的控制器:

[HttpPost]
        public ActionResult Create(Mapper20170129 mapper)
        {
            if (ModelState.IsValid)
            {


                    repository.AddArticle(mapper);

                    return RedirectToAction("Index");
                }
                else
                {
                ModelState.AddModelError("", "Error.");

                }

            return View(mapper);
        }

我已经通过Create ActionResult和Create View获得了其他控制器,但我没有遇到任何问题并且未找到此错误

提前感谢您的帮助

0 个答案:

没有答案