Click here to Skip to main content
15,867,308 members
Articles / Web Development / ASP.NET
Tip/Trick

Creating a Mobile Application Using MVC4

Rate me:
Please Sign up or sign in to vote.
4.00/5 (7 votes)
10 Aug 2012CPOL1 min read 61.9K   19   9
How to build a MVC4 Mobile application.

Introduction

MVC is one of three ASP.NET programming models.

MVC is a framework for building web applications using an MVC (Model View Controller) design:

  • The Model represents the application core (for instance a list of database records).
  • The View displays the data (the database records).
  • The Controller handles the input (to the database records).

The MVC model also provides full control over HTML, CSS, and JavaScript.

Prerequisites

  • Install Visual Studio 2010 (SP1)
  • Install ASP.NET MVC4
  • Install Microsoft SQL Server Compact 4.0
  • Install Opera Mobile Emulator

Getting Started

The following steps will show how to build a MVC4 Mobile application.

Step 1

Open Visual Studio, select New Project -> ASP.NET MVC4 Web Application.

Image 1

Step 2

Select Mobile Application from the Project Template.

Image 2

Step 3

Go to Solution Explorer, right-click on the App_Data folder, and click on Add New Item.

Image 3

Select SQL Server Compact 4.0 Local Database and name it as Movies.sdf.

Step 4

Database is added to the App_Data folder.

Image 4

Step 5

Create a table and name it MovieDBs.

Image 5

Step 6

Add ConnectionString in Web.config.

Image 6

Step 7

Right-click on Model->Add->Class and paste the following code:

Image 7

Note: ConnectionString name and Class name should be the same.

Step 8

Right-click on Controller->Add->Controller Add Controller Window Popup.

Image 8

Click on Add button and it will create a Movies Controller.

Step 9

Run application using Opera Mobile Emulator and it shows the following result.

Image 9

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions

 
QuestionHow to Install the App in the Mobile Pin
Anubhava Dimri16-Jul-14 1:23
Anubhava Dimri16-Jul-14 1:23 
GeneralMy vote of 1 Pin
Rubol22-Sep-13 19:05
professionalRubol22-Sep-13 19:05 
GeneralMy vote of 4 Pin
tgueth26-Feb-13 10:53
professionaltgueth26-Feb-13 10:53 
QuestionDEvelop mobile applications using mvc? Pin
Member 917112810-Dec-12 18:21
Member 917112810-Dec-12 18:21 
Question[My vote of 1] Poor Sample Pin
msdevtech29-Oct-12 16:28
msdevtech29-Oct-12 16:28 
GeneralMy vote of 5 Pin
Nandakishore G N15-Aug-12 21:51
professionalNandakishore G N15-Aug-12 21:51 
Questionneed to know Pin
csharpbd10-Aug-12 13:34
professionalcsharpbd10-Aug-12 13:34 
AnswerRe: need to know Pin
Ravindra T C10-Aug-12 16:32
professionalRavindra T C10-Aug-12 16:32 
Yes, it required browser to run.
GeneralRe: need to know Pin
csharpbd11-Aug-12 2:51
professionalcsharpbd11-Aug-12 2:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.