SET"首页"在Asp.Net MVC [英] Set "Homepage" in Asp.Net MVC

查看:115
本文介绍了SET"首页"在Asp.Net MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在asp.net MVC中的主页(即打www.foo.com时显示的路由)设置为主页/索引。

In asp.net MVC the "homepage" (ie the route that displays when hitting www.foo.com) is set to Home/Index .


  • 在哪里存储这个值?

  • 我怎样才能改变主页?

  • 有什么比在家里控制器的Index操作?
  • 使用RedirectToRoute()更优雅
  • Where is this value stored?
  • How can I change the "homepage"?
  • Is there anything more elegant than using RedirectToRoute() in the Index action of the home controller?

我想在我的项目grepping首页/指数,但没有找到一个参考,我也能看到在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

您可以设置一个默认路由:

You can set up a default route:

        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.

这篇关于SET"首页"在Asp.Net MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆