我一直在处理一些关于路线的问题。我已经定义了路线,但我不断收到 404。以下是路线:
routes.MapRoute(
name: "Default",
url: "{controller}",
defaults: new { controller = "Login", action = "Login" }
);
routes.MapRoute(
name: "Home",
url: "{controller}/{Date}",
defaults: new { controller = "Home", action = "Home", Date = UrlParameter.Optional }
);
routes.MapRoute(
name: "Calendar",
url: "{controller}/{action}",
defaults: new { controller = "Calendar", action = "Index" }
);
routes.MapRoute(
name: "Act",
url: "{controller}",
defaults: new { controller = "Act", action = "New" }
);
localhost:51081/login works!
localhost:51081/Home/25.04.2013 works!
localhost:51081/act doesnt work!
localhost:51081/calendar/index doesnt work!
这里“登录”和“家庭”有效,但“日历”和“行为”无效。当我将“日历”映射移动到顶部时,“家庭”映射不起作用。你如何映射你的页面?
基本上我不希望动作名称出现在 url ex 上:http://localhost:51081/Home/Home/25.04.2013.
我想看到它http://localhost:51081/Home/25.04.2013 or http://localhost:51081/calendar