Model

Model is used to work with application data it is responsible for maintaining application data and business logic. Model Class is kept in the model folder.Model notifies a view for changes(view get data from model).It represents a set of classes that represents the business logic.It is responsible for providing all the business logic and validation to the view.basically model class include public property which will be used by application for manipulating the data.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
 
namespace MvcApplication2.Models
{
    public class Class1
    {
        public String Name { get; set; }
        public String Address { get; set; }
        public String Email { get; set; }
    }
}

View

View is the presentation layer of our project.The view is only responsible for only displaying the data and data is received from the controller as the result. The view is defaultly stored in the view folder.in the view basically we use .cshtml file where we write c# or vb code. When we create view it something look like this and view is binded through model 

@model MvcApplication2.Models.Class1@{
    Layout = null;
}
 
<!DOCTYPE html>
 
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
<body>
    <div>
        <h1>Welcome to the index view</h1>
    </div>
</body>
</html>

Controller


It act as a mediator between view and model and is responsible for controlling the application logic .It send commands to the model to update the model it can also commands to its associated view to change the view.Controller receives input from the view.then process user data with the help of model and passing the results back to the view.it is responsible for controlling the way that a user intracts.it is responsible for what data to be send to user when user  request.


 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
 
namespace MvcApplication2.Controllers
{
    public class Default1Controller : Controller
    {
        //
        // GET: /Default1/
 
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult About()
        {
            return View();
        }
 
    }
}



here this is default controller inheriting controller base class.it has two method


Index() and About(). with respective view.


  Modified On Dec-30-2017 01:31:26 AM

Leave Comment