Definition of MVC
The Model View Controller (MVC) pattern is an architectural design principal that separates components of web applications. This separation gives us more control over individual parts of an application. It lets us easily develop modify and test applications.
The ASP.NET MVC Framework is a lightweight highly testable and presentation framework that integrates with existing ASP.NET features, smarter pages and membership based authentication.
The MVC framework is defined in the System.Web.MVC assemblies.

In this whenever the user requests a page the first hit goes to the controller.
Then the request goes to the view and a View is returned.
Controller / View
Views
- Present data to the user.
- Read only view as well as forms.
- Minimal display only logic
- Most often the views are created from the model data.
Controller
- Responds to the request.
- Connects the model to the view.
- Invokes the model code as appropriate.
- Typically controllers read data from a view, control user input and send input data to the model.
Model
- Domain Specific representation of data
- Business logic
- Often the model objects retrieves data from (and stores data to) a database.
How MVC works 
Flow of M - V - C
Here in the diagram when the user requests a page it either does a GET () or a POST ().
The request goes to the Routing engine.
Then the Controller (Front Controller) is hit.
Then it will see request and return the requested view.
MVC Convention (How to call a Page in MVC)

What is Razor?
- Razor is markup syntax for adding server based code to a webpage.
- Razor is server-side markup syntax much as PHP.
- Razor supports C# and VB Programming Languages.
- A Razor code block is enclosed in:
@{ }
- The code statements end with a semicolon ( ; )
- Variables are declared by Var
- Strings are enclosed with a Quotation mark.
- C# code is case sensitive.
e.g
C# file have Extensions with .cshtml
What id Data Annotation?
In MVC you can validate data in the UI and before sending to the database auto-magically.
If you add Data Annaotation Validators to your model classes then something.
Data annotations are not the only way to specify validation rules, but they're easy to implement.
Add "using System.ComponentModel.DataAnnotations;" to your model.
The following are Data Annotations we can use in a Model:
- DisplayName: Provides a general-purpose attribute that lets you specify localizable strings to display.
- Required: A value is required
- DataType: The data type annotation can be used to specify the data type for validation.
- StringLength: Max. Length of array or string data allowed
- DisplayFormat: Specify the display format for a property like various formats for a Date property.
- ReqularExpression: validate the value of a property by a specified Regular Expression pattern.
- Range: Numeric range constraints for the data field value
- MaxLength: Specify max length for a string property.
- Bind: Specify fields to include or exclude when adding a parameter or form values to model properties.
- Compare: The Compares property compares two properties
- Key: Denotes one or more properties that uniquely identify an entity.
After this start with the first tutorial.

Ankur MistryPosted Mar 20, 2017, 3:36 AM
Nice one Sai, thank you for sharing
SubashPosted Mar 19, 2017, 12:52 AM
Thank you for give such nice article..
Jayashri PatilPosted Feb 18, 2016, 1:44 AM
nice articles..easy to understand..thanks
Suyash SalunkhePosted Feb 10, 2016, 1:43 AM
1 No SaiBahi
Ankur MistryPosted Dec 31, 2015, 2:25 PM
Nice share Saineshwar Bageri
Kundena Mohan GoudPosted Dec 9, 2015, 8:33 AM
Nice article Bageri
jayaprathap sivaPosted Sep 18, 2015, 5:34 AM
thanks to Saineshwar Bageri
vaibhav kamblePosted Mar 14, 2015, 4:22 AM
Nice article Sai
Sandeep SharmaPosted May 19, 2014, 6:00 AM
MVC, has a no. of advantages over web forms, the separation between the Model,View,Controller allows us the easiest way to implement the unit testing of each aspects of our application, we can get a lot more control over fine detail of MVC application, most important it avoids the large amount of state data transfer b/w the server and client that has made the adoption of web forms outside the internet so troublesome and that is the one of reason why we chose ASP.NET over webforms.
Mahesh Kumar AlankaPosted Apr 28, 2014, 1:32 AM
very nice for beginners
Saineshwar BageriPosted Apr 1, 2014, 2:58 AM
thanks sandeep
Sandeep SharmaPosted Mar 27, 2014, 2:12 AM
very informative .. Thanks (y)
Saineshwar BageriPosted Mar 18, 2014, 4:00 AM
thanks Lakshmanan
Lakshmanan Sethu SankaranarayanPosted Mar 18, 2014, 3:08 AM
Nice One :)