【发布时间】:2009-11-13 23:35:22
【问题描述】:
我正在使用 MVC2 Preview 1 开发一个非常简单的应用程序。
我有一个名为 ContentController 的控制器。我的问题是 /Content/Index 工作正常,但 /Content/ 返回 404。我在 Studio Development Server 上运行应用程序。
使用 RouteDebugger 测试,但 /Content/ 返回 404,并且不显示任何调试信息。
我没有更改路由代码:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
这是我的控制器:
public class ContentController : Controller
{
IRepository _repo = new SimpleRepository("db", SimpleRepositoryOptions.RunMigrations);
public ActionResult Index()
{
var content = _repo.GetPaged<Content>(0, 20);
return View(content);
}
【问题讨论】:
-
您是在 IIS 还是可视化 Web 服务器下运行它?如果是 IIS,哪个版本?您是否使用 /Content(与 /Content/)得到相同的结果?
-
嗯...这很奇怪。你能贴一张路由调试器输出的截图吗=
-
我在 Visual Studio 2008 提供的内置 Web 服务器上运行它。
-
/Content 和 /Content/ 的结果相同
标签: asp.net asp.net-mvc asp.net-mvc-routing