You are on page 1of 50

Introduction to .

NET
Florin Olariu
“Alexandru Ioan Cuza”, University of Iași
Department of Computer Science
ASP.NET Core
Agenda

 Understanding ASP.NET Core 1.0


 Web Technologies
 Using Static Content
 Using Dependency Injection with ASP.NET
 Defining Custom Simple Routing
 Creating Middleware Components
 Interview questions
Understanding ASP.NET Core 1.0(1/6)
Understanding ASP.NET Core 1.0(2/6)

 ASP.NET Web Forms is no longer part of ASP.NET Core 1.0.


Understanding ASP.NET Core 1.0(3/6)

 ASP.NET Web Forms is no longer part of ASP.NET Core 1.0.


 ASP.NET MVC is still part of ASP.NET Core 1.0.
Understanding ASP.NET Core 1.0(4/6)

 ASP.NET Web Forms is no longer part of ASP.NET Core 1.0.


 ASP.NET MVC is still part of ASP.NET Core 1.0.
 Converting ASP.NET Web Forms to ASP.NET MVC might be a lot of work.
Understanding ASP.NET Core 1.0(5/6)

 ASP.NET Web Forms is no longer part of ASP.NET Core 1.0.


 ASP.NET MVC is still part of ASP.NET Core 1.0.
 Converting ASP.NET Web Forms to ASP.NET MVC might be a lot of work.
 ASP.NET MVC is based on the Model-View-Controller (MVC) pattern, which
makes unit testing easy.
Understanding ASP.NET Core 1.0(6/6)

 DEMO - TailspinSpyworks
Web Technologies(1/17)
Web Technologies(2/17)

 HTML
Web Technologies(3/17)

 HTML
 HTML5 has been a W3C recommendation since October 2014 (http
://w3.org/TR/html5)
Web Technologies(4/17)

 HTML
 HTML5 has been a W3C recommendation since October 2014 (http
://w3.org/TR/html5)
 With the features of HTML5, several browser add-ins (such as Flash and
Silverlight) are not required anymore
Web Technologies(5/17)

 HTML
 HTML5 has been a W3C recommendation since October 2014 (http
://w3.org/TR/html5)
 With the features of HTML5, several browser add-ins (such as Flash and
Silverlight) are not required anymore
 HTML5 adds new semantic elements that search engines are better able to
use for analyzing the site(canvas, video, audio).
Web Technologies(6/17)

 HTML
 HTML5 has been a W3C recommendation since October 2014 (http
://w3.org/TR/html5)
 With the features of HTML5, several browser add-ins (such as Flash and
Silverlight) are not required anymore
 HTML5 adds new semantic elements that search engines are better able to
use for analyzing the site(canvas, video, audio).
 HTML5 also defines APIs for drag-and-drop, storage, web sockets, and much
more.
Web Technologies(7/17)

 CSS
Web Technologies(8/17)

 CSS
 In the earlier days of HTML the list item tag <li> defined whether list
elements should be displayed with a circle, a disc, or a square.
Web Technologies(9/17)

 CSS
 In the earlier days of HTML the list item tag <li> defined whether list
elements should be displayed with a circle, a disc, or a square.
 You can use flexible selectors to select HTML elements, and you can define
styles for these elements.
Web Technologies(10/17)

 CSS
 In the earlier days of HTML the list item tag <li> defined whether list
elements should be displayed with a circle, a disc, or a square.
 You can use flexible selectors to select HTML elements, and you can define
styles for these elements.
 In Visual Studio 2015, the web project templates make use of Twitter
Bootstrap.
Web Technologies(11/17)

 JavaScript and TypeScript


Web Technologies(12/17)

 JavaScript and TypeScript.


 JavaScript enables accessing the document object model (DOM) from the
HTML page.
Web Technologies(13/17)

 JavaScript and TypeScript.


 JavaScript enables accessing the document object model (DOM) from the
HTML page.
 JavaScript is a functional programming language that is not object-oriented,
although object-oriented capabilities have been added to it.
Web Technologies(14/17)

 JavaScript and TypeScript.


 JavaScript enables accessing the document object model (DOM) from the
HTML page.
 JavaScript is a functional programming language that is not object-oriented,
although object-oriented capabilities have been added to it.
 ECMAScript is the standard that defines the current and upcoming features of
the JavaScript language.
Web Technologies(15/17)

 JavaScript and TypeScript.


 JavaScript enables accessing the document object model (DOM) from the
HTML page.
 JavaScript is a functional programming language that is not object-oriented,
although object-oriented capabilities have been added to it.
 ECMAScript is the standard that defines the current and upcoming features of
the JavaScript language.
 TypeScript syntax is based on ECMAScript, but it has some enhancements,
such as strongly typed code and annotations.
Web Technologies(16/17)

 JavaScript and TypeScript.


 JavaScript enables accessing the document object model (DOM) from the
HTML page.
 JavaScript is a functional programming language that is not object-oriented,
although object-oriented capabilities have been added to it.
 ECMAScript is the standard that defines the current and upcoming features of
the JavaScript language.
 TypeScript syntax is based on ECMAScript, but it has some enhancements,
such as strongly typed code and annotations.
 jQuery (http://www.jquery.org) is a library that abstracts browser
differences when accessing DOM elements and reacting to events.
Web Technologies(17/17)

 JavaScript and TypeScript.


 JavaScript enables accessing the document object model (DOM) from the HTML page.
 JavaScript is a functional programming language that is not object-oriented,
although object-oriented capabilities have been added to it.
 ECMAScript is the standard that defines the current and upcoming features of the
JavaScript language.
 TypeScript syntax is based on ECMAScript, but it has some enhancements, such as
strongly typed code and annotations.
 jQuery (http://www.jquery.org) is a library that abstracts browser differences when
accessing DOM elements and reacting to events.
 Angular (http://angularjs.org) is a library based on the MVC pattern for simplifying
development and testing with single-page web applications.
Using Static Content(1/5)

 Demo
 Empty project
 Global.json
 Project.json
 Debugging
 Startup file
 Environment variables
 launchSettings.json
Using Static Content(2/5)
Using Static Content(3/5)

 In order to enable static files we have to add the extension method


UseStaticFiles()
Using Static Content(4/5)

 In order to enable static files we have to add the extension method


UseStaticFiles()
Using Static Content(5/5)

 Demo
 Empty project
 Add UserStaticFiles()
 Create a static file and see the results
Using Dependency Injection with
ASP.NET(1/12)
 IoC/DI mechanisms
Using Dependency Injection with
ASP.NET(2/12)
 IoC/DI mechanisms
Using Dependency Injection with
ASP.NET(3/12)
 IoC/DI mechanisms
Using Dependency Injection with
ASP.NET(4/12)
 IoC/DI mechanisms

PROS CONS
Helps with adhering to the DI introduces a learning curve for
Dependency Inversion Principle (DIP) some developers
Allows objects to be easily swapped DI may require a significant overhaul
with replacements of existing projects
Facilitates the use of the Strategy Project timelines may not allow DI
Design Pattern (SDP)
Improves the testability of
applications
Enables loose coupling of software
components
Using Dependency Injection with
ASP.NET(5/12)
 IoC/DI mechanisms
Using Dependency Injection with
ASP.NET(6/12)
 IoC/DI mechanisms

 Transient
Using Dependency Injection with
ASP.NET(7/12)
 IoC/DI mechanisms

 Transient
 Scoped
Using Dependency Injection with
ASP.NET(8/12)
 IoC/DI mechanisms

 Transient
 Scoped
 Singleton
Using Dependency Injection with
ASP.NET(9/12)
 IoC/DI mechanisms

 Transient
 Scoped
 Singleton
 Instance (special case of Singleton)
Using Dependency Injection with
ASP.NET(10/12)
 IoC/DI mechanisms

 Transient
 Scoped
 Singleton
 Instance (special case of Singleton)
Using Dependency Injection with
ASP.NET(11/12)
 IoC/DI mechanisms

 Transient
 Scoped
 Singleton
 Instance (special case of Singleton)

 Constructor injection
Using Dependency Injection with
ASP.NET(11/12)
 IoC/DI mechanisms

 Transient
 Scoped
 Singleton
 Instance (special case of Singleton)

 Constructor injection
 Action injection
Using Dependency Injection with
ASP.NET(12/12)
 DEMO
 Using controllers and views
 Using IoC and DI
 Verifying routes
 Creating midlleware
Interview questions(1/1)
One more thing…(1/2)
One more thing…(2/2)

“Truth can only be found in one


place: the code.”
by Robert C. Martin, 
Clean Code: A Handbook of Agile Software Craftsmanship
Bibliography

 https://docs.asp.net/en/latest/tutorials/first-web-api.html - By Mike Wasson


 and Rick Anderson
 Nagel, Christian. Professional C# 6 and .NET Core 1.0
 Chowdhuri, Shahed. ASP.NET Core Essentials
Questions

 Do you have any other questions?


Thanks!
See you next time! 

You might also like