首页 > 解决方案 > 路由配置 - 找不到资源错误 Asp.Net MVC

问题描述

1-我是 Createnew Project MVC Empty 并且我添加了新的控制器名称 Home :

public class Home : Controller

    {
        // GET: Home
        public ActionResult Index()
        {
            return View();
        }
    }

2-我正在索引中移动并添加视图

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_MainLayout.cshtml";
}
<h2>Index</h2>

但是如果我正在调试我的项目,请告诉我 ASP MVC 路由配置 - 找不到资源错误信息:在 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 }
                );
        }

标签: asp.net-mvc

解决方案


推荐阅读