Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Let me start this out by saying I've been a asp.net web forms developer for a while now and that I understand mvc is a new way of doing things. As I'm learning mvc and going through tutorials and training videos, I have questions that these tutorials don't address. This is my attempt to address them here...

I started a new project with the new internet application template in Visual Studio. I'm looking around the project trying to wrap my head around the mvc paradigm and I notice there is a Home and an About page. In the views, there is a file for each of these two pages. That makes sense. But why do they share the same controller? I think it would make sense if I had several screens that edit/view/delete the same data table, but the home and the about page don't necessarily have anything to do with each other. Does this mean if I create other pages that don't need a full blown controller (like a sitemap or something), I should just stick their views in the "Home" views folder? It just doesn't seem right.

I know this basic stuff isn't that big of a deal, but this is the type of stuff that bugs the hell out of me. Thanks in advance for the clarification!

share|improve this question
4  
It isn't right. It's just the bad default the MS put in their MVC template. –  Oded Apr 18 '12 at 13:29

1 Answer 1

up vote 3 down vote accepted

Because it makes a little bit of sense when considering the default routes in the same template. It allows things that 'look nicer' at http://www.foo.com/about rather than having the longer url with a controller in there: http://www.foo.com/controller/about

Not particularly necessary, but that routing is an important concept to understand with ASP.NET MVC.

share|improve this answer
    
Thanks for the response. I see your point. Going with this line of reasoning, I would think instead of calling the controller and the view folder "Home", it should be "Index". It would make more sense to have home, about and whatever to have "index" to be the common denominator, if anything. Perhaps I'm just weird, lol. –  Darren Apr 18 '12 at 13:53
    
You can do that if you'd like. You just have to override the default route. –  Mike Brown Apr 18 '12 at 14:04
    
MVC is full of widely accepted conventions. Has this become the convention to keep the controller and the view folder "home"? If another programmer comes along to support my app, would the consensus be, "wtf", since it strays from the "norm"? –  Darren Apr 18 '12 at 15:12
    
In my limited experience, the Home controller is the name of the default route. The apps have taken different approaches about what it should contain (most have just an index and/or login, some had 5-10 actions) but none have renamed it. –  Telastyn Apr 18 '12 at 15:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.