【发布时间】:2012-06-27 00:39:28
【问题描述】:
我正在开发一个 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 文件中注册一个路由。
-
@PatrickPitre 就是这样!!我不敢相信我错过了!非常感谢。把它写成答案,我会接受的
标签: c# asp.net-mvc-3