SlideShare a Scribd company logo
Building a Basic ASP.NET
MVC 5 Application
1
MVC 5 Application
1. Creating MVC5 project in Visual Studio 2013
• Open Visual Studio Express 2013 for Web and create “New Project” as “File –> New
Project.
• Choose “ASP.NET Web Application” template as shown in following figure. Name the
project as “MyFirstMVC5App”, choose location and press “OK” button.
2
MVC 5 Application
. In next dialog, choose “MVC” as template and again press “OK” button.
3
MVC 5 Application
. A new ASP.NET MVC 5 project will be created as follows. You can easily find the
“Controllers”, “Models” and “Views” folder in solution explorer.
4
MVC 5 Application
2. Preparing a Model
• In order to prepare a model, right click on “Models” folder and choose “Add”, then
“Class”.
• Name the class as “Employee.cs”.
5
MVC 5 Application
public class Employee
{ public string EmpID { get; set; }
public string EmpFirstName { get; set; }
public string EmpLastName { get; set; }
}
Model is the representation of data structure in our Data
Source, so you can assume this “Employee” class represents
an Employee table in our database with columns as “EmpID”,
“EmpFirstName”, “EmpLastName” and so on.
6
MVC 5 Application
• 3. Add a Controller
• To add a controller to our project, right click on “Controllers” folder, choose “Add”, then
“Controller”.
• From “Add Scaffold” dialog, choose “MVC 5 Controller – Empty” and press “Add” button
as follows:
7
MVC 5 Application
8
• Name the controller as “EmployeeController” in next dialog and
press “Add”. A new controller will be added to “Controllers” folder.
Controller code generated will be as follows:
MVC 5 Application
9
namespace MyFirstMVC5App.Controllers
{ public class EmployeeController : Controller
{ // GET: /Employee/
public ActionResult Index()
{ return View();
}
}
}
• EmployeeController inheriting from base Controller class has a method named Index(). This
Index() method will be the default method called when accessing this controller as
(http://localhost:xxxx/Employee/).
• In order to generate HTML response, above Index() method uses a view template i.e.
represented in code as “return View();”
• As we create a controller, a new folder will be created under “Views” named as
“Employee”.
MVC 5 Application
10
4. Add a View
• Finally for adding a view, right click on newly created “Employee” folder under views,
choose “Add”, then “MVC 5 View Page (Razor)”. Specify the name for the view “Index” as
follows:
MVC 5 Application
11
A new file with the name “Index.cshtml” will be added under “Views->Employee” folder. I
have added meaningful some text to this page as shown in below figure.
MVC 5 Application
12
Now, we are done with creating a simple ASP.NET MVC 5 application. To run the application,
click CTRL + F5.
Or
hange the URL in browser from above to http://localhost:11517/Employee/ and press enter,
still the output remains the same.
Result will be as follows:

More Related Content

PPT
MSDN - ASP.NET MVC
PDF
Aspnet mvc tutorial_01_cs
PPT
ASP.NET Session 5
PPTX
Katalon Studio - GUI Overview
PPT
ASP.NET Session 6
PDF
Windows Phone Workshop: WCF services
PPTX
ASP.NET MVC Presentation
PPT
Custom Controls in ASP.net
MSDN - ASP.NET MVC
Aspnet mvc tutorial_01_cs
ASP.NET Session 5
Katalon Studio - GUI Overview
ASP.NET Session 6
Windows Phone Workshop: WCF services
ASP.NET MVC Presentation
Custom Controls in ASP.net

What's hot (19)

PPT
ASP.NET Session 9
PPTX
Custom control in asp.net
PPTX
Custom controls
PDF
ASP.NET MVC 3
PPTX
Mule management console installation
PPTX
ASP.NET MVC.
 
PDF
Test Case Creation in Katalon Studio
DOCX
Create rest webservice for oracle public api using java class via jdeveloper
PPT
Asp.net mvc
DOCX
ASP.NET MVC3 RAD
PPT
ASP .net MVC
PPTX
Automation Testing of Shadow DOM Elements with Katalon Studio
PDF
Tutorial - 14 How to insert a verification point from the script explorer usi...
PPT
Microsoft VS C++ Add a project
DOCX
Ajux calender extender
PPTX
Creating custom Validators on Reactive Forms using Angular 6
PPTX
Github plugin setup in anypointstudio
PPTX
Html Server Anchor Control VB
PPTX
MVC Training Part 2
ASP.NET Session 9
Custom control in asp.net
Custom controls
ASP.NET MVC 3
Mule management console installation
ASP.NET MVC.
 
Test Case Creation in Katalon Studio
Create rest webservice for oracle public api using java class via jdeveloper
Asp.net mvc
ASP.NET MVC3 RAD
ASP .net MVC
Automation Testing of Shadow DOM Elements with Katalon Studio
Tutorial - 14 How to insert a verification point from the script explorer usi...
Microsoft VS C++ Add a project
Ajux calender extender
Creating custom Validators on Reactive Forms using Angular 6
Github plugin setup in anypointstudio
Html Server Anchor Control VB
MVC Training Part 2
Ad

Similar to Asp 2-createaspnetmvc (20)

PDF
ASP.NET MVC 5 Building Your First Web Application (A Beginner S Guide
PDF
Asp 1-mvc introduction
PPTX
ASP.NET MVC 5 - EF 6 - VS2015
PDF
Getting started with entity framework 6 code first using mvc 5
PPTX
Getting started with MVC 5 and Visual Studio 2013
PPTX
Introduction to ASP.Net MVC
PPTX
PDF
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
PPT
AspMVC4 start101
PPTX
Asp.Net MVC 5 in Arabic
PDF
ASP.NET MVC - Whats The Big Deal
PPTX
2011 NetUG HH: ASP.NET MVC & HTML 5
DOCX
LearningMVCWithLINQToSQL
PPTX
Asp.net With mvc handson
PPT
CTTDNUG ASP.NET MVC
PDF
Mastering asp.net mvc - Dot Net Tricks
DOCX
A report on mvc using the information
PPTX
ASP.NET MVC Fundamental
PPTX
Hanselman lipton asp_connections_ams304_mvc
PPS
Introduction To Mvc
ASP.NET MVC 5 Building Your First Web Application (A Beginner S Guide
Asp 1-mvc introduction
ASP.NET MVC 5 - EF 6 - VS2015
Getting started with entity framework 6 code first using mvc 5
Getting started with MVC 5 and Visual Studio 2013
Introduction to ASP.Net MVC
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
AspMVC4 start101
Asp.Net MVC 5 in Arabic
ASP.NET MVC - Whats The Big Deal
2011 NetUG HH: ASP.NET MVC & HTML 5
LearningMVCWithLINQToSQL
Asp.net With mvc handson
CTTDNUG ASP.NET MVC
Mastering asp.net mvc - Dot Net Tricks
A report on mvc using the information
ASP.NET MVC Fundamental
Hanselman lipton asp_connections_ams304_mvc
Introduction To Mvc
Ad

More from Fajar Baskoro (20)

PPTX
Pengembangan Basis Data untuk Web Application.pptx
PPTX
Presentasi untuk video Pitch Deck Vlog Pervekt SMK 2025.pptx
PPTX
Sosialisasi Program Digital Skills Unicef 2025.pptx
PDF
DIGITAL SKILLS PROGRAMME 2025 - VERSI HZ.pdf
PDF
Digital Skills - 2025 - Dinas - Green Marketplace.pdf
PDF
Pemrograman Mobile menggunakan kotlin2.pdf
PPTX
Membangun Kewirausahan Sosial Program Double Track.pptx
PPTX
Membangun Kemandirian DTMandiri-2025.pptx
PDF
Panduan Entry Nilai Rapor untuk Operator SD_MI 2025.pptx (1).pdf
PDF
JADWAL SISTEM PENERIMAAN MURID BARU 2025.pdf
PPTX
Seleksi Penerimaan Murid Baru 2025.pptx
PPTX
Pengembangan Program Dual Track 2025-2.pptx
PPTX
Pengembangan Program Dual Track 2025-1.pptx
PDF
PETUNJUK PELAKSANAAN TEKNIS FESV RAMADHAN 2025.pdf
PPTX
Pengembangan Entrepreneur Vokasi Melalui PERFECT SMK-Society 50 .pptx
PPTX
PERFECT SMK 6 - Strategi Pelaksanaan.pptx
PPTX
Program Dual Track Kalimantan Timur 2025.pptx
PDF
Contoh Proposal konveksi untuk Program Magang Kewirausahaan.pdf
PPTX
Pengembangan Program Digital Skills - 2025.pptx
PPTX
PPT-Proyek Magang Kewirausahaan Double Track.pptx
Pengembangan Basis Data untuk Web Application.pptx
Presentasi untuk video Pitch Deck Vlog Pervekt SMK 2025.pptx
Sosialisasi Program Digital Skills Unicef 2025.pptx
DIGITAL SKILLS PROGRAMME 2025 - VERSI HZ.pdf
Digital Skills - 2025 - Dinas - Green Marketplace.pdf
Pemrograman Mobile menggunakan kotlin2.pdf
Membangun Kewirausahan Sosial Program Double Track.pptx
Membangun Kemandirian DTMandiri-2025.pptx
Panduan Entry Nilai Rapor untuk Operator SD_MI 2025.pptx (1).pdf
JADWAL SISTEM PENERIMAAN MURID BARU 2025.pdf
Seleksi Penerimaan Murid Baru 2025.pptx
Pengembangan Program Dual Track 2025-2.pptx
Pengembangan Program Dual Track 2025-1.pptx
PETUNJUK PELAKSANAAN TEKNIS FESV RAMADHAN 2025.pdf
Pengembangan Entrepreneur Vokasi Melalui PERFECT SMK-Society 50 .pptx
PERFECT SMK 6 - Strategi Pelaksanaan.pptx
Program Dual Track Kalimantan Timur 2025.pptx
Contoh Proposal konveksi untuk Program Magang Kewirausahaan.pdf
Pengembangan Program Digital Skills - 2025.pptx
PPT-Proyek Magang Kewirausahaan Double Track.pptx

Recently uploaded (20)

PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Insiders guide to clinical Medicine.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
01-Introduction-to-Information-Management.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Cell Structure & Organelles in detailed.
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Basic Mud Logging Guide for educational purpose
PDF
Computing-Curriculum for Schools in Ghana
PPTX
Cell Types and Its function , kingdom of life
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Lesson notes of climatology university.
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Pharma ospi slides which help in ospi learning
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Insiders guide to clinical Medicine.pdf
PPH.pptx obstetrics and gynecology in nursing
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
01-Introduction-to-Information-Management.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
TR - Agricultural Crops Production NC III.pdf
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
Cell Structure & Organelles in detailed.
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Basic Mud Logging Guide for educational purpose
Computing-Curriculum for Schools in Ghana
Cell Types and Its function , kingdom of life
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Supply Chain Operations Speaking Notes -ICLT Program
Lesson notes of climatology university.
human mycosis Human fungal infections are called human mycosis..pptx
Pharma ospi slides which help in ospi learning

Asp 2-createaspnetmvc

  • 1. Building a Basic ASP.NET MVC 5 Application 1
  • 2. MVC 5 Application 1. Creating MVC5 project in Visual Studio 2013 • Open Visual Studio Express 2013 for Web and create “New Project” as “File –> New Project. • Choose “ASP.NET Web Application” template as shown in following figure. Name the project as “MyFirstMVC5App”, choose location and press “OK” button. 2
  • 3. MVC 5 Application . In next dialog, choose “MVC” as template and again press “OK” button. 3
  • 4. MVC 5 Application . A new ASP.NET MVC 5 project will be created as follows. You can easily find the “Controllers”, “Models” and “Views” folder in solution explorer. 4
  • 5. MVC 5 Application 2. Preparing a Model • In order to prepare a model, right click on “Models” folder and choose “Add”, then “Class”. • Name the class as “Employee.cs”. 5
  • 6. MVC 5 Application public class Employee { public string EmpID { get; set; } public string EmpFirstName { get; set; } public string EmpLastName { get; set; } } Model is the representation of data structure in our Data Source, so you can assume this “Employee” class represents an Employee table in our database with columns as “EmpID”, “EmpFirstName”, “EmpLastName” and so on. 6
  • 7. MVC 5 Application • 3. Add a Controller • To add a controller to our project, right click on “Controllers” folder, choose “Add”, then “Controller”. • From “Add Scaffold” dialog, choose “MVC 5 Controller – Empty” and press “Add” button as follows: 7
  • 8. MVC 5 Application 8 • Name the controller as “EmployeeController” in next dialog and press “Add”. A new controller will be added to “Controllers” folder. Controller code generated will be as follows:
  • 9. MVC 5 Application 9 namespace MyFirstMVC5App.Controllers { public class EmployeeController : Controller { // GET: /Employee/ public ActionResult Index() { return View(); } } } • EmployeeController inheriting from base Controller class has a method named Index(). This Index() method will be the default method called when accessing this controller as (http://localhost:xxxx/Employee/). • In order to generate HTML response, above Index() method uses a view template i.e. represented in code as “return View();” • As we create a controller, a new folder will be created under “Views” named as “Employee”.
  • 10. MVC 5 Application 10 4. Add a View • Finally for adding a view, right click on newly created “Employee” folder under views, choose “Add”, then “MVC 5 View Page (Razor)”. Specify the name for the view “Index” as follows:
  • 11. MVC 5 Application 11 A new file with the name “Index.cshtml” will be added under “Views->Employee” folder. I have added meaningful some text to this page as shown in below figure.
  • 12. MVC 5 Application 12 Now, we are done with creating a simple ASP.NET MVC 5 application. To run the application, click CTRL + F5. Or hange the URL in browser from above to http://localhost:11517/Employee/ and press enter, still the output remains the same. Result will be as follows: