设置“主页"在 Asp.Net MVC 中 [英] Set "Homepage" in Asp.Net MVC
问题描述
在 asp.net MVC 中,主页"(即点击 www.foo.com 时显示的路由)设置为 Home/Index .
In asp.net MVC the "homepage" (ie the route that displays when hitting www.foo.com) is set to Home/Index .
- 这个值存储在哪里?
- 如何更改主页"?
- 有什么比在家庭控制器的 Index 动作中使用 RedirectToRoute() 更优雅的吗?
我尝试在我的项目中搜索主页/索引,但找不到参考,也无法在 IIS (6) 中看到任何内容.我查看了根目录中的 default.aspx 页面,但这似乎没有做任何相关的事情.
I tried grepping for Home/Index in my project and couldn't find a reference, nor could I see anything in IIS (6). I looked at the default.aspx page in the root, but that didn't seem to do anything relevent.
谢谢
推荐答案
查看Default.aspx/Default.aspx.cs
和Global.asax.cs
Look at the Default.aspx/Default.aspx.cs
and the Global.asax.cs
您可以设置默认路由:
routes.MapRoute(
"Default", // Route name
"", // URL with parameters
new { controller = "Home", action = "Index"} // Parameter defaults
);
只需将控制器/操作名称更改为您想要的默认值.那应该是路由表中的最后一条路由.
Just change the Controller/Action names to your desired default. That should be the last route in the Routing Table.
这篇关于设置“主页"在 Asp.Net MVC 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!