开发者

I need to change my MVC2 home page to a different page

How can one go about doing that. I am betting it has something to do with the routing engine.开发者_高级运维 Not sure though. I will continue to browse the interwebs...


You're right, you will want to change your default route. It is in the Global.asax.cs file (by default).

The default one looks like this:

routes.MapRoute(
    "Default", // Route name
    "{controller}/{action}/{id}", // URL with parameters
    new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);

This line:

new { controller = "Home", action = "Index", id = UrlParameter.Optional }

Is the defaults. The default controller name is Home and the default action is Index. Change them to what you desire.

You can learn more about routing here.


Look at your default route. Out of the box, it will point to the index method of the home controller.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜