0

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!

asked Apr 18, 2012 at 13:25
1
  • 4
    It isn't right. It's just the bad default the MS put in their MVC template. Commented Apr 18, 2012 at 13:29

1 Answer 1

3

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.

answered Apr 18, 2012 at 13:40
4
  • 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. Commented Apr 18, 2012 at 13:53
  • You can do that if you'd like. You just have to override the default route. Commented Apr 18, 2012 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"? Commented Apr 18, 2012 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. Commented Apr 18, 2012 at 15:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.