为什么这不起作用?
路线:
routes.MapRoute(
"Summary",
"{controller}/{id}",
new { controller = "Summary", action = "Default" }
);
控制器:
public class SummaryController : Controller
{
public ActionResult Default(int id)
{
Summary summary = GetSummaryById(id);
return View("Summary", summary);
}
}
网址:
http://localhost:40353/Summary/107
错误:
Server Error in '/' Application.
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: /Summary/107
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225
更新:
让我用一个更聪明的问题来更新这个问题。我怎么能同时拥有这两个?
routes.MapRoute(
"Home",
"{controller}",
new { controller = "Home", action = "Default" }
);
routes.MapRoute(
"Summary",
"{controller}/{id}",
new { controller = "Summary", action = "Default" }
);