tags:

views:

52

answers:

2

I'm just getting into ASP.NET MVC and was a little confused in the sample app why 'HomeController' is called 'HomeController'.

It seems to be a better name would be 'DefaultController' or 'ContentController'.

Its really a little misleading because its name implies that its got something to do with controlling the homepage, but it really doesnt.

The contents of the controller is this, and it loads content pages defined in the 'Home' directory.

 [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewData["Title"] = "Home Page";
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            ViewData["Title"] = "About Page";

            return View();
        }

        public ActionResult AnotherPage()
        {
            ViewData["Title"] = "About my other page";

            return View();
        }
    }

Agree or disagree?

+1  A: 

Home is pretty ubiquitous on the web (Home Page). I think it's a perfectly reasonable choice for the name of the default controller. I actually prefer it over default or content because default implies that there is some alternative and content, in my mind, applies to all of my application entirely or to the specific HTML rendered on each page, depending on the context.

tvanfosson
the problem is that it controls the about us page as well and not just the homepage. You could argue that 'about us' is a 'sub page' of the homepage. it just confused me a little at first when i'm trying to figure where to put in static content pages
Simon_Weaver
A: 

I think the name is OK. Not great. They could have done a lot worse.

This is what I would consider a "framework quirk" - Just something you have to buy into to get the good stuff (patterns/productivity/reuse/etc) from a framework.

tyndall