SlideShare a Scribd company logo
Asp.net core tutorial
ASP.NET Core
i
AbouttheTutorial
ASP.NET Core is the new web framework from Microsoft. ASP.NET Core is the framework
you want to use for web development with .NET. At the end this tutorial, you will have
everything you need to start using ASP.NET Core and write an application that can create,
edit, and view data from a database.
Audience
This tutorial is designed for software programmers who would like to learn the basics of
ASP.NET Core from scratch.
Prerequisites
You should have a basic understanding of Computer Programming terminologies. A basic
understanding of any of the programming languages is a plus.
Disclaimer&Copyright
 Copyright 2016 by Tutorials Point (I) Pvt. Ltd.
All the content and graphics published in this e-book are the property of Tutorials Point (I)
Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish
any contents or a part of contents of this e-book in any manner without written consent
of the publisher.
We strive to update the contents of our website and tutorials as timely and as precisely as
possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt.
Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our
website or its contents including this tutorial. If you discover any errors on our website or
in this tutorial, please notify us at contact@tutorialspoint.com.
ASP.NET Core
ii
TableofContents
About the Tutorial..................................................................................................................................i
Audience ................................................................................................................................................i
Prerequisites ..........................................................................................................................................i
Disclaimer & Copyright...........................................................................................................................i
Table of Contents ..................................................................................................................................ii
1. ASP.NET — OVERVIEW.......................................................................................................1
A Brief History of ASP.NET.....................................................................................................................1
What is ASP.NET Core............................................................................................................................1
Advantages of ASP.NET Core .................................................................................................................2
2. ASP.NET CORE — ENVIRONMENT SETUP...........................................................................3
Installation of Microsoft Visual Studio 2015 ..........................................................................................3
3. ASP.NET CORE — NEW PROJECT........................................................................................9
4. ASP.NET CORE — PROJECT LAYOUT.................................................................................13
5. ASP.NET CORE — PROJECT.JSON......................................................................................20
6. ASP.NET CORE — CONFIGURATION .................................................................................25
7. ASP.NET CORE — MIDDLEWARE......................................................................................30
How to Add another Middleware........................................................................................................33
8. ASP.NET CORE — EXCEPTIONS.........................................................................................37
9. ASP.NET CORE — STATIC FILES.........................................................................................41
10. ASP.NET CORE — SETUP MVC..........................................................................................49
ASP.NET Core
iii
11. ASP.NET CORE — MVC DESIGN PATTERN ........................................................................56
Idea behind MVC.................................................................................................................................56
12. ASP.NET CORE — ROUTING .............................................................................................59
13. ASP.NET CORE — ATTRIBUTE ROUTES .............................................................................68
14. ASP.NET CORE — ACTION RESULTS..................................................................................73
15. ASP.NET CORE — VIEWS..................................................................................................79
16. ASP.NET CORE — SETUP ENTITY FRAMEWORK................................................................85
17. ASP.NET CORE — DBCONTEXT.........................................................................................89
18. ASP.NET CORE — RAZOR LAYOUT VIEWS.......................................................................104
19. ASP.NET CORE — RAZOR VIEW START ...........................................................................109
20. ASP.NET CORE — RAZOR VIEW IMPORT ........................................................................112
21. ASP.NET CORE — RAZOR TAG HELPERS .........................................................................117
22. ASP.NET CORE — RAZOR EDIT FORM.............................................................................125
23. ASP.NET CORE — IDENTITY OVERVIEW..........................................................................135
24. ASP.NET CORE — AUTHORIZE ATTRIBUTE......................................................................138
25. ASP.NET CORE — IDENTITY CONFIGURATION................................................................149
26. ASP.NET CORE — IDENTITY MIGRATIONS ......................................................................160
27. ASP.NET CORE — USER REGISTRATION..........................................................................165
28. ASP.NET CORE — CREATE A USER..................................................................................173
29. ASP.NET CORE — LOG IN AND LOG OUT........................................................................178
ASP.NET Core
4
ASP.NET Core is the new web framework from Microsoft. It has been redesigned from the
ground up to be fast, flexible, modern, and work across different platforms. Moving forward,
ASP.NET Core is the framework that can be used for web development with .NET. If you have
any experience with MVC or Web API over the last few years, you will notice some familiar
features. At the end this tutorial, you will have everything you need to start using ASP.NET
Core and write an application that can create, edit, and view data from a database.
ABriefHistoryofASP.NET
ASP.NET has been used from many years to develop web applications. Since then, the
framework went through a steady evolutionary change and finally led us to its most recent
descendant ASP.NET Core 1.0.
 ASP.NET Core 1.0 is not a continuation of ASP.NET 4.6.

 It is a whole new framework, a side-by-side project which happily lives alongside
everything else we know.

 It is an actual re-write of the current ASP.NET 4.6 framework, but much smaller and
a lot more modular.

 Some people think that many things remain the same, but this is not entirely true.
ASP.NET Core 1.0 is a big fundamental change to the ASP.NET landscape.
WhatisASP.NETCore
ASP.NET Core is an open source and cloud-optimized web framework for developing modern
web applications that can be developed and run on Windows, Linux and the Mac. It includes
the MVC framework, which now combines the features of MVC and Web API into a single web
programming framework.
 ASP.NET Core apps can run on .NET Core or on the full .NET Framework.

 It was architected to provide an optimized development framework for apps that are
deployed to the cloud or run on-premises.

 It consists of modular components with minimal overhead, so you retain flexibility
while constructing your solutions.

1. ASP.NET —OVERVIEW
ASP.NET Core
5
 You can develop and run your ASP.NET Core apps cross-platform on Windows, Mac
and Linux.

AdvantagesofASP.NETCore
ASP.NET Core comes with the following advantages:
 ASP.NET Core has a number of architectural changes that result in a much leaner and
modular framework.

 ASP.NET Core is no longer based on System.Web.dll. It is based on a set of granular
and well factored NuGet packages.

 This allows you to optimize your app to include just the NuGet packages you need.

 The benefits of a smaller app surface area include tighter security, reduced servicing,
improved performance, and decreased costs
With ASP.NET Core, you can get the following improvements:
 Build and run cross-platform ASP.NET apps on Windows, Mac and Linux

 Built on .NET Core, which supports true side-by-side app versioning

 New tooling that simplifies modern wWeb development

 Single aligned web stack for Web UI and Web APIs

 Cloud-ready environment-based configuration

 Built-in support for dependency injection

 Tag Helpers which makes Razor markup more natural with HTML

 Ability to host on IIS or self-host in your own process
ASP.NET Core
6
ASP.NET Core is a significant redesign of ASP.NET. This topic introduces the new concepts in
ASP.NET Core and explains how they help you develop modern web apps.
To use ASP.NET Core in your application, the following must be installed in your system:
 Microsoft Visual Studio 2015

 Microsoft .NET Core 1.0.0 - VS 2015 Tooling Preview 2
Microsoft provides a free version of Visual Studio which also contains the SQL Server and it
can be downloaded from https://www.visualstudio.com/en-us/downloads/download-visual-
studio-vs.aspx and Microsoft .NET Core 1.0.0 - VS 2015 Tooling Preview 2 can be downloaded
from https://go.microsoft.com/fwlink/?LinkId=817245.
InstallationofMicrosoftVisualStudio2015
Let us now understand the steps involved in the installation of
Step 1: Once downloading is completed, run the installer. The following dialog box will be
displayed.
2. ASP.NET CORE — ENVIRONMENT SETUP
ASP.NET Core
7
ASP.NET Core
8
Step 2: Click the Install button as in the above screenshot. The installation process will then
start.
ASP.NET Core
9
Step 3: Once the installation process is completed successfully, you will see the following
dialog box.
Step 4: Close this dialog and restart your computer if required.
ASP.NET Core
10
Step 5: Open the Visual studio from the Start menu. This will open the following dialog box
and it will take some time for the first time (only for preparation).
ASP.NET Core
11
Step 6: You will now see the main window of the Visual studio.
Step 7: Once the Visual Studio is installed, close the Visual Studio and launch the Microsoft
.NET Core 1.0.0 - VS 2015 Tooling Preview 2
ASP.NET Core
12
Step 8: Check the checkbox and click Install.
Step 9: Once the installation is completed, you will see the following message.
ASP.NET Core
13
Step 10: You are now ready to start your application using ASP.NET Core.
ASP.NET Core
14
In this chapter, we will discuss how to create a new project in Visual Studio.
Once you have installed the Visual Studio 2015 tooling, you can start building a new ASP.NET
Core Application from the File > New Project menu option.
On the New Project dialog box, you will see the following three different templates for Web
projects:
 ASP.NET Web Application: The simple ASP.NET application templates

 ASP.NET Core Web Application (.NET Core): This will start you with a cross-
platform compatible project that runs on the .NET Core framework

 ASP.NET Core Web Application (.NET Framework): This starts a new project that
runs on the standard .NET Framework on Windows.
3. ASP.NET CORE — NEW PROJECT
ASP.NET Core
15
In the left pane, select Templates > Visual C# > Web and in the middle pane select the
ASP.NET Core Web Application (.NET Core) template. Let us call this application
FirstAppDemo and also specify the Location for your ASP.NET Core project and then Click
OK.
In the above dialog box, you can select a specific template for the ASP.NET application from
the available ASP.NET Core Templates.
ASP.NET Core templates currently contain three different templates. Of these, the Web
Application template will help you lay out a lot of files on your file system. This also allows
you to use ASP.NET MVC right away.
Here, we will start with an empty template. This would help us build it from scratch. Let us
select the Empty template, turn off the Host in the cloud and click OK.
ASP.NET Core
16
Visual Studio will now launch the project in some time. In the Solution Explorer window, you
will see all the files that are in this project.
Let us run this application, you can do that by pressing Ctrl+F5 or by going to the Debug
menu. After going to the Debug menu, select Start Without Debugging.
ASP.NET Core
17
This application can display only Hello World! This runs on localhost:57741. In the window
system tray, you can also see that IIS Express is running.
ASP.NET Core
18
And the name of the site is FirstAppDemo. If you have been programming with ASP.NET
with the previous versions of the framework, the way you would interact with the Visual Studio
and the way Visual Studio uses IIS Express to host your application, all these aspects will be
familiar.
ASP.NET Core
19
In this chapter, we will discuss how ASP.NET core project appears on the file system and how
the different files and directories all work together.
Let us open the FirstAppDemo project created in the previous chapter.
4. ASP.NET CORE — PROJECT LAYOUT
ASP.NET Core
20
In the Solution Explorer window, right-click on the Solution node and select the Open Folder
in File Explorer.
You will see now the root directory with two files in it: FirstAppDemo.sln and global.json.
ASP.NET Core
21
FirstAppDemo.sln is a solution file. Visual Studio has used this extension for years by
default, and you can double-click on the file if you want to open the app in Studio and work
on it.
There is also a global.json file. Let us open this file in Visual Studio.
ASP.NET Core
22
In the file, the project's setting is significant. This project setting tells ASP.NET where to look
for your source code and what folders contain your projects.
There are two possible folders “src” for source and a “test” folder. Unless your projects and
source code are in one of these two folders, the code won't be available to build. You can
change these settings if you want.
The Windows Explorer has the “src” folder on disk. You don't have a test folder. In the test
folder, you could place your unit testing projects. Let us double-click on the “src” folder.
ASP.NET Core
23
You can see the FirstAppDemo project, and the web application. Now, double-click on the
folder.
ASP.NET Core
24
These are the source code files for the application and you can also see this folder structure
in the Solution Explorer window. This is because in the present version of ASP.NET Core, the
file system determines what is in your project.
ASP.NET Core
25
End of ebook preview
If you liked what you saw…
Buy it from our store @ https://store.tutorialspoint.com

More Related Content

What's hot (19)

PDF
Howto Create & Run zf2skeleton Apps with PHP's Built-in Webserver
Master Zend Framework
 
PPTX
Last Month in PHP - January 2016
Eric Poe
 
PPTX
Python Programming Essentials - M2 - Introduction to Python
P3 InfoTech Solutions Pvt. Ltd.
 
PPTX
Developing .NET Core AWS Lambda functions
Deniz İrgin
 
PDF
Using serverless with aws
Mariana Bocoi
 
PPTX
Олексій Гончар "Використання Electron в розробці корпоративної відео-мессeндж...
OdessaJS Conf
 
PPTX
Build 2017 - B8096 - Ten things you didn’t know about Visual Studio 2017 for ...
Windows Developer
 
PDF
"13 ways to run web applications on the Internet" Andrii Shumada
Fwdays
 
PPTX
TechUG - Kubernetes 101 - May 2020
Elton Stoneman
 
PPT
Behat sauce
Shashikant Jagtap
 
PPTX
Pluralsight Webinar: Simplify Your Project Builds with Docker
Elton Stoneman
 
PDF
Cloud Foundry Meetup Stuttgart 2017 - Spring Cloud Development
Andreas Falk
 
PDF
Dennis Benkert - The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
D
 
PPTX
The Dog Ate My Deployment - PHP Uncoference September 2013
D
 
PPTX
Service Configuration Management for Rapid Growth - demo 10 steps to build pi...
Takashi Someda
 
PDF
The Dog Ate My Deployment - Symfony Usergroup Cologne July 2013
D
 
PPTX
Build 2017 - B8083 - The future of Visual Studio
Windows Developer
 
PDF
Виталий Редько "React + Redux: performance & scalability"
Fwdays
 
PPTX
Walk in the shoe of angular
Fiyaz Hasan
 
Howto Create & Run zf2skeleton Apps with PHP's Built-in Webserver
Master Zend Framework
 
Last Month in PHP - January 2016
Eric Poe
 
Python Programming Essentials - M2 - Introduction to Python
P3 InfoTech Solutions Pvt. Ltd.
 
Developing .NET Core AWS Lambda functions
Deniz İrgin
 
Using serverless with aws
Mariana Bocoi
 
Олексій Гончар "Використання Electron в розробці корпоративної відео-мессeндж...
OdessaJS Conf
 
Build 2017 - B8096 - Ten things you didn’t know about Visual Studio 2017 for ...
Windows Developer
 
"13 ways to run web applications on the Internet" Andrii Shumada
Fwdays
 
TechUG - Kubernetes 101 - May 2020
Elton Stoneman
 
Behat sauce
Shashikant Jagtap
 
Pluralsight Webinar: Simplify Your Project Builds with Docker
Elton Stoneman
 
Cloud Foundry Meetup Stuttgart 2017 - Spring Cloud Development
Andreas Falk
 
Dennis Benkert - The Dog Ate My Deployment - Symfony Usergroup Berlin March ...
D
 
The Dog Ate My Deployment - PHP Uncoference September 2013
D
 
Service Configuration Management for Rapid Growth - demo 10 steps to build pi...
Takashi Someda
 
The Dog Ate My Deployment - Symfony Usergroup Cologne July 2013
D
 
Build 2017 - B8083 - The future of Visual Studio
Windows Developer
 
Виталий Редько "React + Redux: performance & scalability"
Fwdays
 
Walk in the shoe of angular
Fiyaz Hasan
 

Similar to Asp.net core tutorial (20)

PDF
Murach: An introduction to web programming with ASP.NET Core MVC
MahmoudOHassouna
 
PDF
Why Enterprises are Using ASP.NET Core?
Marie Weaver
 
PDF
introduction to asp.net core lebanese university.pptx
husseinhazimeh20
 
PPTX
Quick Interview Preparation Dot Net Core
Karmanjay Verma
 
PDF
Asp.net Web Development.pdf
Sonia Simi
 
PPTX
Full session asp net mvc vs aspnet core
fizmhd
 
PDF
Learning Aspnet Core Mvc Programming Mugilan T S Ragupathi
nybiadegeye
 
PPTX
Explore asp.net core 3.0 features
iFour Technolab Pvt. Ltd.
 
PDF
Asp. net core 3.0 build modern web and cloud applications (top 13 features +...
Katy Slemon
 
PDF
Why ASP.Net Core is Ideal for Developing High-Performance Enterprise Apps.pdf
SeasiaInfotech2
 
PDF
Top 8 Reasons ASP.NET Core is the Best Framework for Web Application Developm...
WDP Technologies
 
PPTX
Introduction-to-ASPNET-Core ASP.NET.pptx
MAHERMOHAMED27
 
PPTX
ASP.NET Core: The best of the new bits
Ken Cenerelli
 
PDF
Pro ASP.NET Core 7, MEAP V03 10th Edition Adam Freeman
poralilyrou
 
PDF
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
Arrow Consulting & Design
 
PDF
Pro ASP.NET Core 6: Develop Cloud-Ready Web Applications Using MVC, Blazor, a...
madhowewes
 
PPTX
Getting started with dotnet core Web APIs
Knoldus Inc.
 
PDF
ASP.NET Core Interview Questions PDF By ScholarHat.pdf
Scholarhat
 
PDF
Asp.Net Core MVC , Razor page , Entity Framework Core
mohamed elshafey
 
PDF
5 Ways ASP.Net Core Enhances Enterprise Application Performance.pdf
SeasiaInfotech2
 
Murach: An introduction to web programming with ASP.NET Core MVC
MahmoudOHassouna
 
Why Enterprises are Using ASP.NET Core?
Marie Weaver
 
introduction to asp.net core lebanese university.pptx
husseinhazimeh20
 
Quick Interview Preparation Dot Net Core
Karmanjay Verma
 
Asp.net Web Development.pdf
Sonia Simi
 
Full session asp net mvc vs aspnet core
fizmhd
 
Learning Aspnet Core Mvc Programming Mugilan T S Ragupathi
nybiadegeye
 
Explore asp.net core 3.0 features
iFour Technolab Pvt. Ltd.
 
Asp. net core 3.0 build modern web and cloud applications (top 13 features +...
Katy Slemon
 
Why ASP.Net Core is Ideal for Developing High-Performance Enterprise Apps.pdf
SeasiaInfotech2
 
Top 8 Reasons ASP.NET Core is the Best Framework for Web Application Developm...
WDP Technologies
 
Introduction-to-ASPNET-Core ASP.NET.pptx
MAHERMOHAMED27
 
ASP.NET Core: The best of the new bits
Ken Cenerelli
 
Pro ASP.NET Core 7, MEAP V03 10th Edition Adam Freeman
poralilyrou
 
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
Arrow Consulting & Design
 
Pro ASP.NET Core 6: Develop Cloud-Ready Web Applications Using MVC, Blazor, a...
madhowewes
 
Getting started with dotnet core Web APIs
Knoldus Inc.
 
ASP.NET Core Interview Questions PDF By ScholarHat.pdf
Scholarhat
 
Asp.Net Core MVC , Razor page , Entity Framework Core
mohamed elshafey
 
5 Ways ASP.Net Core Enhances Enterprise Application Performance.pdf
SeasiaInfotech2
 
Ad

More from HarikaReddy115 (20)

PDF
Dbms tutorial
HarikaReddy115
 
PDF
Data structures algorithms_tutorial
HarikaReddy115
 
PDF
Wireless communication tutorial
HarikaReddy115
 
PDF
Cryptography tutorial
HarikaReddy115
 
PDF
Cosmology tutorial
HarikaReddy115
 
PDF
Control systems tutorial
HarikaReddy115
 
PDF
Computer logical organization_tutorial
HarikaReddy115
 
PDF
Computer fundamentals tutorial
HarikaReddy115
 
PDF
Compiler design tutorial
HarikaReddy115
 
PDF
Communication technologies tutorial
HarikaReddy115
 
PDF
Biometrics tutorial
HarikaReddy115
 
PDF
Behavior driven development_tutorial
HarikaReddy115
 
PDF
Basics of computers_tutorial
HarikaReddy115
 
PDF
Basics of computer_science_tutorial
HarikaReddy115
 
PDF
Basic electronics tutorial
HarikaReddy115
 
PDF
Auditing tutorial
HarikaReddy115
 
PDF
Artificial neural network_tutorial
HarikaReddy115
 
PDF
Artificial intelligence tutorial
HarikaReddy115
 
PDF
Antenna theory tutorial
HarikaReddy115
 
PDF
Analog communication tutorial
HarikaReddy115
 
Dbms tutorial
HarikaReddy115
 
Data structures algorithms_tutorial
HarikaReddy115
 
Wireless communication tutorial
HarikaReddy115
 
Cryptography tutorial
HarikaReddy115
 
Cosmology tutorial
HarikaReddy115
 
Control systems tutorial
HarikaReddy115
 
Computer logical organization_tutorial
HarikaReddy115
 
Computer fundamentals tutorial
HarikaReddy115
 
Compiler design tutorial
HarikaReddy115
 
Communication technologies tutorial
HarikaReddy115
 
Biometrics tutorial
HarikaReddy115
 
Behavior driven development_tutorial
HarikaReddy115
 
Basics of computers_tutorial
HarikaReddy115
 
Basics of computer_science_tutorial
HarikaReddy115
 
Basic electronics tutorial
HarikaReddy115
 
Auditing tutorial
HarikaReddy115
 
Artificial neural network_tutorial
HarikaReddy115
 
Artificial intelligence tutorial
HarikaReddy115
 
Antenna theory tutorial
HarikaReddy115
 
Analog communication tutorial
HarikaReddy115
 
Ad

Recently uploaded (20)

PPTX
Difference between write and update in odoo 18
Celine George
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PPTX
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
PDF
epi editorial commitee meeting presentation
MIPLM
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPTX
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
PPTX
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PPTX
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
PPTX
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
PDF
Introduction presentation of the patentbutler tool
MIPLM
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PPTX
infertility, types,causes, impact, and management
Ritu480198
 
Difference between write and update in odoo 18
Celine George
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
epi editorial commitee meeting presentation
MIPLM
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Aprendendo Arquitetura Framework Salesforce - Dia 03
Mauricio Alexandre Silva
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Vani - The Voice of Excellence - Jul 2025 issue
Savipriya Raghavendra
 
Nitrogen rule, ring rule, mc lafferty.pptx
nbisen2001
 
Horarios de distribución de agua en julio
pegazohn1978
 
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
TRANSLATIONAL AND ROTATIONAL MOTION.pptx
KIPAIZAGABAWA1
 
Introduction presentation of the patentbutler tool
MIPLM
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
infertility, types,causes, impact, and management
Ritu480198
 

Asp.net core tutorial

  • 2. ASP.NET Core i AbouttheTutorial ASP.NET Core is the new web framework from Microsoft. ASP.NET Core is the framework you want to use for web development with .NET. At the end this tutorial, you will have everything you need to start using ASP.NET Core and write an application that can create, edit, and view data from a database. Audience This tutorial is designed for software programmers who would like to learn the basics of ASP.NET Core from scratch. Prerequisites You should have a basic understanding of Computer Programming terminologies. A basic understanding of any of the programming languages is a plus. Disclaimer&Copyright  Copyright 2016 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at [email protected].
  • 3. ASP.NET Core ii TableofContents About the Tutorial..................................................................................................................................i Audience ................................................................................................................................................i Prerequisites ..........................................................................................................................................i Disclaimer & Copyright...........................................................................................................................i Table of Contents ..................................................................................................................................ii 1. ASP.NET — OVERVIEW.......................................................................................................1 A Brief History of ASP.NET.....................................................................................................................1 What is ASP.NET Core............................................................................................................................1 Advantages of ASP.NET Core .................................................................................................................2 2. ASP.NET CORE — ENVIRONMENT SETUP...........................................................................3 Installation of Microsoft Visual Studio 2015 ..........................................................................................3 3. ASP.NET CORE — NEW PROJECT........................................................................................9 4. ASP.NET CORE — PROJECT LAYOUT.................................................................................13 5. ASP.NET CORE — PROJECT.JSON......................................................................................20 6. ASP.NET CORE — CONFIGURATION .................................................................................25 7. ASP.NET CORE — MIDDLEWARE......................................................................................30 How to Add another Middleware........................................................................................................33 8. ASP.NET CORE — EXCEPTIONS.........................................................................................37 9. ASP.NET CORE — STATIC FILES.........................................................................................41 10. ASP.NET CORE — SETUP MVC..........................................................................................49
  • 4. ASP.NET Core iii 11. ASP.NET CORE — MVC DESIGN PATTERN ........................................................................56 Idea behind MVC.................................................................................................................................56 12. ASP.NET CORE — ROUTING .............................................................................................59 13. ASP.NET CORE — ATTRIBUTE ROUTES .............................................................................68 14. ASP.NET CORE — ACTION RESULTS..................................................................................73 15. ASP.NET CORE — VIEWS..................................................................................................79 16. ASP.NET CORE — SETUP ENTITY FRAMEWORK................................................................85 17. ASP.NET CORE — DBCONTEXT.........................................................................................89 18. ASP.NET CORE — RAZOR LAYOUT VIEWS.......................................................................104 19. ASP.NET CORE — RAZOR VIEW START ...........................................................................109 20. ASP.NET CORE — RAZOR VIEW IMPORT ........................................................................112 21. ASP.NET CORE — RAZOR TAG HELPERS .........................................................................117 22. ASP.NET CORE — RAZOR EDIT FORM.............................................................................125 23. ASP.NET CORE — IDENTITY OVERVIEW..........................................................................135 24. ASP.NET CORE — AUTHORIZE ATTRIBUTE......................................................................138 25. ASP.NET CORE — IDENTITY CONFIGURATION................................................................149 26. ASP.NET CORE — IDENTITY MIGRATIONS ......................................................................160 27. ASP.NET CORE — USER REGISTRATION..........................................................................165 28. ASP.NET CORE — CREATE A USER..................................................................................173 29. ASP.NET CORE — LOG IN AND LOG OUT........................................................................178
  • 5. ASP.NET Core 4 ASP.NET Core is the new web framework from Microsoft. It has been redesigned from the ground up to be fast, flexible, modern, and work across different platforms. Moving forward, ASP.NET Core is the framework that can be used for web development with .NET. If you have any experience with MVC or Web API over the last few years, you will notice some familiar features. At the end this tutorial, you will have everything you need to start using ASP.NET Core and write an application that can create, edit, and view data from a database. ABriefHistoryofASP.NET ASP.NET has been used from many years to develop web applications. Since then, the framework went through a steady evolutionary change and finally led us to its most recent descendant ASP.NET Core 1.0.  ASP.NET Core 1.0 is not a continuation of ASP.NET 4.6.   It is a whole new framework, a side-by-side project which happily lives alongside everything else we know.   It is an actual re-write of the current ASP.NET 4.6 framework, but much smaller and a lot more modular.   Some people think that many things remain the same, but this is not entirely true. ASP.NET Core 1.0 is a big fundamental change to the ASP.NET landscape. WhatisASP.NETCore ASP.NET Core is an open source and cloud-optimized web framework for developing modern web applications that can be developed and run on Windows, Linux and the Mac. It includes the MVC framework, which now combines the features of MVC and Web API into a single web programming framework.  ASP.NET Core apps can run on .NET Core or on the full .NET Framework.   It was architected to provide an optimized development framework for apps that are deployed to the cloud or run on-premises.   It consists of modular components with minimal overhead, so you retain flexibility while constructing your solutions.  1. ASP.NET —OVERVIEW
  • 6. ASP.NET Core 5  You can develop and run your ASP.NET Core apps cross-platform on Windows, Mac and Linux.  AdvantagesofASP.NETCore ASP.NET Core comes with the following advantages:  ASP.NET Core has a number of architectural changes that result in a much leaner and modular framework.   ASP.NET Core is no longer based on System.Web.dll. It is based on a set of granular and well factored NuGet packages.   This allows you to optimize your app to include just the NuGet packages you need.   The benefits of a smaller app surface area include tighter security, reduced servicing, improved performance, and decreased costs With ASP.NET Core, you can get the following improvements:  Build and run cross-platform ASP.NET apps on Windows, Mac and Linux   Built on .NET Core, which supports true side-by-side app versioning   New tooling that simplifies modern wWeb development   Single aligned web stack for Web UI and Web APIs   Cloud-ready environment-based configuration   Built-in support for dependency injection   Tag Helpers which makes Razor markup more natural with HTML   Ability to host on IIS or self-host in your own process
  • 7. ASP.NET Core 6 ASP.NET Core is a significant redesign of ASP.NET. This topic introduces the new concepts in ASP.NET Core and explains how they help you develop modern web apps. To use ASP.NET Core in your application, the following must be installed in your system:  Microsoft Visual Studio 2015   Microsoft .NET Core 1.0.0 - VS 2015 Tooling Preview 2 Microsoft provides a free version of Visual Studio which also contains the SQL Server and it can be downloaded from https://www.visualstudio.com/en-us/downloads/download-visual- studio-vs.aspx and Microsoft .NET Core 1.0.0 - VS 2015 Tooling Preview 2 can be downloaded from https://go.microsoft.com/fwlink/?LinkId=817245. InstallationofMicrosoftVisualStudio2015 Let us now understand the steps involved in the installation of Step 1: Once downloading is completed, run the installer. The following dialog box will be displayed. 2. ASP.NET CORE — ENVIRONMENT SETUP
  • 9. ASP.NET Core 8 Step 2: Click the Install button as in the above screenshot. The installation process will then start.
  • 10. ASP.NET Core 9 Step 3: Once the installation process is completed successfully, you will see the following dialog box. Step 4: Close this dialog and restart your computer if required.
  • 11. ASP.NET Core 10 Step 5: Open the Visual studio from the Start menu. This will open the following dialog box and it will take some time for the first time (only for preparation).
  • 12. ASP.NET Core 11 Step 6: You will now see the main window of the Visual studio. Step 7: Once the Visual Studio is installed, close the Visual Studio and launch the Microsoft .NET Core 1.0.0 - VS 2015 Tooling Preview 2
  • 13. ASP.NET Core 12 Step 8: Check the checkbox and click Install. Step 9: Once the installation is completed, you will see the following message.
  • 14. ASP.NET Core 13 Step 10: You are now ready to start your application using ASP.NET Core.
  • 15. ASP.NET Core 14 In this chapter, we will discuss how to create a new project in Visual Studio. Once you have installed the Visual Studio 2015 tooling, you can start building a new ASP.NET Core Application from the File > New Project menu option. On the New Project dialog box, you will see the following three different templates for Web projects:  ASP.NET Web Application: The simple ASP.NET application templates   ASP.NET Core Web Application (.NET Core): This will start you with a cross- platform compatible project that runs on the .NET Core framework   ASP.NET Core Web Application (.NET Framework): This starts a new project that runs on the standard .NET Framework on Windows. 3. ASP.NET CORE — NEW PROJECT
  • 16. ASP.NET Core 15 In the left pane, select Templates > Visual C# > Web and in the middle pane select the ASP.NET Core Web Application (.NET Core) template. Let us call this application FirstAppDemo and also specify the Location for your ASP.NET Core project and then Click OK. In the above dialog box, you can select a specific template for the ASP.NET application from the available ASP.NET Core Templates. ASP.NET Core templates currently contain three different templates. Of these, the Web Application template will help you lay out a lot of files on your file system. This also allows you to use ASP.NET MVC right away. Here, we will start with an empty template. This would help us build it from scratch. Let us select the Empty template, turn off the Host in the cloud and click OK.
  • 17. ASP.NET Core 16 Visual Studio will now launch the project in some time. In the Solution Explorer window, you will see all the files that are in this project. Let us run this application, you can do that by pressing Ctrl+F5 or by going to the Debug menu. After going to the Debug menu, select Start Without Debugging.
  • 18. ASP.NET Core 17 This application can display only Hello World! This runs on localhost:57741. In the window system tray, you can also see that IIS Express is running.
  • 19. ASP.NET Core 18 And the name of the site is FirstAppDemo. If you have been programming with ASP.NET with the previous versions of the framework, the way you would interact with the Visual Studio and the way Visual Studio uses IIS Express to host your application, all these aspects will be familiar.
  • 20. ASP.NET Core 19 In this chapter, we will discuss how ASP.NET core project appears on the file system and how the different files and directories all work together. Let us open the FirstAppDemo project created in the previous chapter. 4. ASP.NET CORE — PROJECT LAYOUT
  • 21. ASP.NET Core 20 In the Solution Explorer window, right-click on the Solution node and select the Open Folder in File Explorer. You will see now the root directory with two files in it: FirstAppDemo.sln and global.json.
  • 22. ASP.NET Core 21 FirstAppDemo.sln is a solution file. Visual Studio has used this extension for years by default, and you can double-click on the file if you want to open the app in Studio and work on it. There is also a global.json file. Let us open this file in Visual Studio.
  • 23. ASP.NET Core 22 In the file, the project's setting is significant. This project setting tells ASP.NET where to look for your source code and what folders contain your projects. There are two possible folders “src” for source and a “test” folder. Unless your projects and source code are in one of these two folders, the code won't be available to build. You can change these settings if you want. The Windows Explorer has the “src” folder on disk. You don't have a test folder. In the test folder, you could place your unit testing projects. Let us double-click on the “src” folder.
  • 24. ASP.NET Core 23 You can see the FirstAppDemo project, and the web application. Now, double-click on the folder.
  • 25. ASP.NET Core 24 These are the source code files for the application and you can also see this folder structure in the Solution Explorer window. This is because in the present version of ASP.NET Core, the file system determines what is in your project.
  • 26. ASP.NET Core 25 End of ebook preview If you liked what you saw… Buy it from our store @ https://store.tutorialspoint.com