【发布时间】:2015-04-03 13:34:56
【问题描述】:
我有一个带有 1 个默认路由的简单 Web 应用程序:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Game", action = "Index", id = UrlParameter.Optional }
);
我的控制器包含以下操作:
public class GameController : Controller
{
public ActionResult Index()
{
// some actions
return View();
}
[HttpPost]
public ActionResult CreateGame(Game game, User user)
{
// some actions
return View("Game");
}
[HttpPost]
public ActionResult JoinGame(User user)
{
// some actions
return View("Game");
}
}
还在 Views/Game 文件夹下,我得到了“Index”和“Game”视图。 但是当我不时启动应用程序时(不总是!)它会请求
http://localhost:55815/Game/Game
而不是
http://localhost:55815 or http://localhost:55815/Game/Index
【问题讨论】:
标签: c# asp.net-mvc razor asp.net-mvc-routing