Reputation: 11
I hope I can address this question correctly.
I want to create a page that follows the MVC architecture.
However, I'm confused of the starting point. I can create a new ASP.NET website in Visual Studio 2010 and it will give default files and folders, but I can't seem to "connect the dots".
I think using the default VS 2010 ASP.NET project might not be a good way to start something with an MVC architecture. What will be a good way to start with a website that could display something which follows MVC?
So what's confusing me are the following: 1. How do you start designing the website when you're thinking of an MVC architecture? 2. How do you put the code-behind? 3. How can you get yourself more organized and make all your code intuitive for a start with MVC?
Your inputs are greatly appreciated Thanks!
Upvotes: 0
Views: 176
Reputation: 18351
Sounds like your first step needs to be installing Microsoft's ASP.NET MVC tools, which will give you a new set of project templates.
These project templates give you a simple sample app and basic MVC folder structure that will help you get started.
The MVC pattern and ASP.NET MVC are big topics that will take some study to understand. If you're coming from a Webforms (traditional ASP.NET MVC) background, you're going to feel like there's a lot of "magic" going on that you don't understand.
That's due to ASP.NET MVC's use of naming conventions to wire things up instead of explicitly declaring them in code or a config
file somewhere. You'll hear this referred to as "convention over configuration", and it was the hardest thing to get used to for me.
Definitely play with some code samples, but before you go too far, I'd recommend reading Professional ASP.NET MVC3. It's an excellent start to finish walkthrough of the MVC pattern and ASP.NET MVC from some of the guys who helped develop the framework. It's very approachable for MVC newbies and will help you with the mental shift if you have a Webforms backgound already.
Upvotes: 0
Reputation: 42497
The starting project is fine. You first must understand the definition and relationship between Model, View, and Controller.
Model is any object representing the data which your view is responsible for displaying. A controller is responsible for accepting the request, finding the appropriate model, and sending it to the appropriate view. The view just displays what the controller asks it to display.
As far as how to start, think of each controller as servicing requests to a specific resource or functional boundary in your application. For example, in the default MVC template, you have an Accounts controller, and a Home controller. Those controllers are responsible for handling user login/logout, resets, etc., and then displaying a user's home page (respectively).
So think about what your site does and organize it similarly, into functional components. Within each component, there are specific operations or tasks a user wishes to perform, which in the MVC world are called Actions, which are just methods on a controller.
As for your #2 question, there is no codebehind in MVC. All the backend stuff you'd normally do in a codebehind is done in the controller in your action method, and any view-related stuff is done in the view page. So a codebehind is superfluous and unnecessary.
Upvotes: 0
Reputation: 6500
Why don't you start with the original guide?
There are many starter projects like the "Music shop".
Try to go here: http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/getting-started-with-mvc3-part1-cs
Upvotes: 2
Reputation: 38825
This is a bit of a very broad question, and I suspect you've not yet researched MVC particularly thoroughly.
This article provides a tutorial on building a movie-database from the ground up.
There are lots of thinks and information from the main portal page.
Upvotes: 3