Complete Guide To ASP - Net Core MVC 3.1
Complete Guide To ASP - Net Core MVC 3.1
1
1. Introduction to Razor Pages in .Net Core 3.1
2. MVC Architecture with .Net Core 3.1
3. Entity Framework Core 3.1
4. Identity Security with EF Core 3.1
5. N-Tier Architecture
6. Dapper and Stored Procedures in EF Core 3.1
7. Repository Pattern
8. Payments using Stripe and BrainTree
9. 2 Factor Authentication, Emails and SMS Notifications
10. Role Management, Session, TempData, Custom Tag Helpers, View Components
and much more…
11. Deployment to Azure
12. Best Practices, Error debugging and Assignments!
CRUD operations
Routing
Action Wizards
Bulkybook.azurewebsites.net
Authorized company can send emails, if their email is registered. They will get flexibility
to make payments within 30 days once the order is placed.
Note: In Visual Studio 2017, .Net Core 3.1 will not work.
dotnet.microsoft.com/download/dotnet-core/3.1
microsoft.com/en-us/sql-server/sql-server/downloads
Bhrugen.com
ASP – 1996
ASP.Net Webform – 2002
ASP.Net MVC – 2009
ASP.Net Core – 2016
ASP.Net Core 2 – 2017
ASP.Net Core 3, 3.1 – 2019 Q4
Razor Project
Visual Studio 2019 -> Create a new project
Create a new ASP.Net Core Web Application (.Net Core/.Net Framework) (ASP.Net Core
1.0/1.1/2.0/2.1/2.2/3.0/3.1) -> Web Application
Note: Razor Pages will be used inside the Identity in MVC application.
Razor Pages
o Introduced in ASP.Net Core 2.0.
o Razor Pages is a new feature of ASP.Net Core MVC that makes coding page-
focused scenarios easier and more productive.
o Razor Pages is not just for simple scenarios, everything that you can do with MVC
you can do by using Razor Pages like Routing, Models, ActionResult, Tag Helpers
and so on.
o Razor Pages has two parts
1. Razor Page (UI/View)
2. Page Model (Contains Handlers)
Tools > NuGet Package Manager > Manage NuGet Packages for Solution…
Browse > Newtonsoft.json (Select) > Project (Check) and BookListRazor (Check) >
Install (Click).
Microsoft.AspNetCore.App was the metapackage which contains all features of .Net Core.
LaunchSettings
Properties > LaunchSettings.json – This file will consist of the settings to be applied after
running the application.
iisSettings setting will host iisExpress which in turn hosts the application and
starts a browser that hits the URL.
profiles setting will set the environment variables to development or production
(environmentVariables).
In IIS Express sub setting, launch variables can be set.
Note: We can use environment variable to load full CSS in development environment or
if it is production environment, we can load minified version of CSS.
Note: The settings can also be set by going into the properties of the project under
‘Debug’ section.
Note: In order to test the settings, we can change the “IIS Express” setting present in
Standard toolbar to the respective setting and later test the application.
wwwroot
This folder consists of the static files in their respective sub folders css, js and lib
(Bootstrap and JQuery validation files).
Pages Folder
This is main folder inside any razor project.
It consists of a shared folder called ‘Shared’. They are partial views. Hence their
name precedes with an underscore.
Note: Partial pages are like user components. You can reuse them in multiple places in
your website.
_Layout.cshtml file is the default master page for your application. It consists
of header, body (div), footer and scripts that we want throughout the
application.
_ValidationScriptsPartial file consists of references to JQuery validation
functions.
_ViewImports.cshtml file consists of @addTagHelper directive that will
include Microsoft.AspNetCore.Mvc.TagHelpers. These will have global scope.
We can also include custom tag helpers into our application.
_ViewStart.cshtml file will consists of the master filename for our application.
Error.cshtml, Index.cshtml and Privacy.cshtml are actual razor pages (views). Each
file will their own respective (Page) model files (like Index.cshtml.cs).
URL Maps To
www.domain.com /Pages/Index.cshtml
www.domain.com/index /Pages/Index.cshtml
Tag Helpers
Tag Helpers are introduced with .Net Core.
Tag Helpers enable server-side code to participate in creating and rendering HTML
elements in Razor files.
Tag Helpers are very focused around the HTML elements and much more natural to use.
Note: HTML Helpers are just methods throughout your Razor marker. They are present in
earlier versions of ASP.Net Core MVC.
There are few Tag Helpers in _Layout.cshtml file. They are listed below:
Similarly, we can set tag helpers for labels, forms and buttons.
@*-----HTML Helper-----*@
@*-----Tag Helper--------*@
@*-----HTML Helper-----*@
@*-----Tag Helper--------*@
Note: HTML Helpers are not so user-friendly. Label uses asp-for tag helper.
Global.asax file consists of methods in which you can write custom logic.
In ASP.Net Core, Global.asax file will not be present. Startup is defined by you and that
starts with Program class file. It consists of Main method.
It deals with the configuration on how ASP.Net Core deals with web server configuration
files, routing and so on.