0% found this document useful (0 votes)
7 views

Tutorial 01 - Create ASP - NET Core MVC Project

file
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Tutorial 01 - Create ASP - NET Core MVC Project

file
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Tutorial 1 – Create ASP.

NET CORE MVC project

1. Open Visual Studio and create new ASP.NET Core MVC web app

Figure 1 - Create new project in Visual Studio

2. Config ASP.NET Core project

Figure 2 - Search & select ASP.NET Core Web App (MVC)

Figure 3 – Set project location, solution & project name


Figure 4 – Setup automatic database connection & Authentication

3. Add model to automatically create table

Figure 5 - Add new Model (class)


Figure 6 – Models/Laptop.cs (1)

4. Generate Controller with Views for CRUD features with Scaffolding technique

Figure 7 - Add new controller (class)

Figure 8 - Select MVC Controller with views

Figure 9 - Select Model class & DbContext class


Figure 10 - Controller & Views have been generated for selected Model

5. Override Identity pages to customize view of Authentication (Login, Register,…)

Figure 11 - Add new Scaffolded Item

Figure 12 - Select option Identity


Figure 13 - Override all files & select DBContext class

Figure 14 - All Identity pages were displayed to be overridden

6. Customize web layout & other web pages

Figure 15 - Views/Shared/_Layout.cshtml
Figure 16 - Views/Home/Index.cshtml

Figure 17 - Views/Laptops/Index.cshtml

7. Add model (form) validation

Figure 18 - Models/Laptop.cs (2)


8. Seed initial data to database

Figure 19 - Data/ApplicationDbContext.cs (1)

Figure 20 - Data/ApplicationDbContext.cs (2)


Figure 21 - Data/ApplicationDbContext.cs (3)

Figure 22 - Data/ApplicationDbContext.cs (4)


Figure 23 - Program.cs

9. Setup role-based access for different features


o Restrict user access in backend (controller)

Figure 24 - Controllers/LaptopsController.cs (1)

Figure 25 - Controllers/LaptopsController.cs (2)

Figure 26 - Controllers/LaptopsController.cs (3)

o Restrict user access in frontend (view)

Figure 27 - Views/Laptops/Index.cshtml
10.Migrate data to database

Figure 28 - Open Package Manager Console (PMC)

Figure 29 - Add migration & update database using PMC

Figure 30 - Run web app with https or IIS Express web server
11. Sample final result

Figure 31 - Homepage

Figure 32 - Login page

Figure 33 - Register page


Figure 34 - View laptop list

Figure 35 - Create new laptop

Figure 36 - Edit existing laptop


Figure 37 - Delete existing laptop

Figure 38 - Access denied page

You might also like