How to set change a default View in MVC3 when debbuging the project in Visual Studio 2010.
As soon I hit F5, The default View it opens is Localhost/Home/Index.
Where is it being set, How do I update it?
Can anyone shed some light on this please? It is not straight forward(for me though).
Thank you
All you have to do is changed your default
MapRouteparameters. Typically, this is what you’ll see by default as yourDefaultroute:Just change the
controllerproperty and theactionproperty to what you want your default to be. For instance, you could do:All that is changed here is the
controllerandactionproperties. Now when you browse to just the qualified name, it will go to yourAnotherController.aDifferentAction()method, instead of theHomeController.Index()method.Explanation
The reason why it defaults to
Home.Index(), is because that is the first matched route when you have empty route parameters forcontrollerandaction. By changing these defaults in theMapRoute()call, you are telling routing that if nothing is there for the route parameters, go toAnotherController.aDifferentAction()action method.As long as this is the first route, you should be set.