Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 应用程序启动时未加载主索引_C#_Asp.net Mvc 3 - Fatal编程技术网

C# 应用程序启动时未加载主索引

C# 应用程序启动时未加载主索引,c#,asp.net-mvc-3,C#,Asp.net Mvc 3,我正在开发一个ASP.NET MVC3应用程序 在视图中,我创建了一个名为Home的文件夹和一个名为Index的视图 然后我创建了一个控制器HomeController 在控制器中,我添加了: public ActionResult Index() { return View(); } 但是,当我运行应用程序时,会出现以下错误: The resource cannot be found. Description: HTTP 404. The resour

我正在开发一个ASP.NET MVC3应用程序

在视图中,我创建了一个名为Home的文件夹和一个名为Index的视图

然后我创建了一个控制器HomeController

在控制器中,我添加了:

    public ActionResult Index()
    {
        return View();
    }
但是,当我运行应用程序时,会出现以下错误:

The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

Requested URL: /
如果我添加到地址栏:/Home/Index,视图将正常加载

如何使应用程序在加载时自动转到主页/索引


感谢您的帮助

您需要向Global.asax文件添加指向您路径的路由

routes.MapRoute("Default", "{controller}/{action}/{id}",
            new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);

听起来您需要在Global.asax文件中注册路由。@PatrickPitre就是这样!!我真不敢相信我错过了!!。谢谢。只要把它写下来作为答案,我会接受它的副本