---
title: "Creating a Simple Model Using ASP.NET MVC4"  
description: "In this article, I will look to create a simple customerInformation model using ASP.NET MVC3."  
author: "Vijay Shukla"  
published: 2012-11-26  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/1064/creating-a-simple-model-using-asp-dot-net-mvc4  
category: "asp.net mvc"  
tags: ["asp.net mvc"]  
reading_time: 3 minutes  

---

# Creating a Simple Model Using ASP.NET MVC4

In this article, I will look to create a simple customerInformation model using ASP.NET MVC3.\

Here is I have two Views, one (Index.cshtml) is for enter data in

\

CustomerInformation Model and second (ShowData.cshtml) is for show the

\

CustomerInformation Model data.

\

Steps for creating a new Application in ASP.NET MVC4

\

1. Open studio 2010 and create a new ASP.NET MVC 4 [Web Application](https://www.mindstick.com/articles/13069/progressive-web-application-pwas-all-you-need-to-know-about) (Razor) project as seen below:

![Creating a simple model using ASP.NET MVC4](https://www.mindstick.com/mindstickarticle/63bce1d2-3d08-48a1-a325-57754b1f000e/images/df651e28-aba9-473a-9e53-0ae0342a7c94.png)

Select the Empty Template and then select the Razor in View Engine Drop Down ListBox Then Press Ok:

![Creating a simple model using ASP.NET MVC4](https://www.mindstick.com/mindstickarticle/63bce1d2-3d08-48a1-a325-57754b1f000e/images/7a49a205-b0fd-4e7f-8210-987b13a9b401.png)

Add a [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc) in [your project](https://www.mindstick.com/forum/156583/best-way-to-link-bootstrap-file-in-your-project) and give name as HomeController as shown in the below figure:

![Creating a simple model using ASP.NET MVC4](https://www.mindstick.com/mindstickarticle/63bce1d2-3d08-48a1-a325-57754b1f000e/images/e1f29ea2-0537-46da-9ff3-3cd1bc3e2cb9.png)

4. Add a Model Class in your project and give name as CustomerInformation as

\

shown in the below figure:

![Creating a simple model using ASP.NET MVC4](https://www.mindstick.com/mindstickarticle/63bce1d2-3d08-48a1-a325-57754b1f000e/images/f66a6107-0674-416d-9aa8-6fb0b45e3e8b.png)

5. Add two Views in the project first view with the Name Index it’s create with

\

Strongly type and [second view](https://www.mindstick.com/forum/33623/problem-in-moving-value-from-second-view-to-first-view-controller-in-iphone) with the name ShowData and it’s also create

\

Strogly type.

##### Index.cshtml

```
@model CustomerInformationMVC3.Models.CustomerInformation
@{
    ViewBag.Title = "Index";
}
@*<script type="text/javascript">
    function s() {
        location.href = "/Home/ShowData"
    }
</script>*@
@using (Html.BeginForm("ShowData", "Home"))
{
  @Html.Label("Customer Name:: ");
  @Html.TextBoxFor(m => m.customer_Name)<br />
  @Html.Label("Customer Age:: ");
   @Html.TextBoxFor(m => m.customer_Age)<br />
   @Html.Label("Customer Contact:: ");
   @Html.TextBoxFor(m => m.customer_Contact)<br />
   @Html.Label("Customer Address:: ");
   @Html.TextBoxFor(m => m.customer_Address)<br />
  <input type="submit" value="Submit" />
}
```

ShowData.cshtml

```
@model CustomerInformationMVC3.Models.CustomerInformation

@{
    ViewBag.Title = "ShowData";
}

<h2>ShowData</h2>

Customer Name&nbsp @Model.customer_Name <br />
Customer Age&nbsp @Model.customer_Age <br />
Customer Contact&nbsp @Model.customer_Contact <br />
Customer Address&nbsp @Model.customer_Address <br />
```

##### HomeController

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CustomerInformationMVC3.Models;

namespace CustomerInformationMVC3.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/
        public ActionResult Index()
        {

            return View();
        }
        public ActionResult ShowData(CustomerInformation _customerInformation)
        {
            return View(_customerInformation);
        }
    }
}
```

[Model Class](https://www.mindstick.com/forum/2281/filter-objects-inside-model-class-by-date) CustomerInformation

\

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
 
namespace CustomerInformationMVC3.Models
{
    public class CustomerInformation
    {
        public string customer_Name{ get; set; }
        public string customer_Address{ get; set; }
        public int customer_Age{ get; set; }
        public string customer_Contact{ get; set; }
    }
} 
```

##### Run this application, you will see the following screen:

![Creating a simple model using ASP.NET MVC4](https://www.mindstick.com/mindstickarticle/63bce1d2-3d08-48a1-a325-57754b1f000e/images/a0fcefc7-37d0-4010-91d3-686e5d2bbc17.png)

##### You can enter the customer Name, Age, Contact, Address and press Submit

##### \

##### After press Submit Button , you will see the following screen:

![Creating a simple model using ASP.NET MVC4](https://www.mindstick.com/mindstickarticle/63bce1d2-3d08-48a1-a325-57754b1f000e/images/bd5ea927-31a3-4c78-b17f-bc012df0c6c4.png)

---

Original Source: https://www.mindstick.com/articles/1064/creating-a-simple-model-using-asp-dot-net-mvc4

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
