Download presentation
Presentation is loading. Please wait.
1
Introduction to .NET Florin Olariu
“Alexandru Ioan Cuza”, University of Iași Department of Computer Science
2
ASP.NET Core
3
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
4
Understanding ASP.NET Core 1.0(1/6)
After 15 years of ASP.NET, ASP.NET Core 1.0 is a complete rewrite of ASP.NET. It features modular programming, is fully open sourced, is lightweight for best use on the cloud, and is available to non-Microsoft platforms.
5
Understanding ASP.NET Core 1.0(2/6)
ASP.NET Web Forms is no longer part of ASP.NET Core 1.0. However, having web applications that include this technology does not mean you have to rewrite them. It’s still possible to maintain legacy applications written with ASP.NET Web Forms with the full framework. ASP.NET Web Forms even received some enhancements with the newest version ASP.NET 4.6, such as asynchronous model binding.
6
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. Because ASP.NET MVC 6 has been completely rewritten, you need to make some changes to web applications written with ASP.NET MVC 5 or older versions to bring them to the new application stack.
7
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. ASP.NET Web Forms abstracts HTML and JavaScript from the developer. Using ASP.NET Web Forms, it’s not necessary to know HTML and JavaScript. Instead you use server-side controls with C# code. The server-side controls themselves return HTML and JavaScript. This programming model is similar to the old Windows Forms programming model.
8
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. ASP.NET Web Forms abstracts HTML and JavaScript from the developer. Using ASP.NET Web Forms, it’s not necessary to know HTML and JavaScript. Instead you use server-side controls with C# code. The server-side controls themselves return HTML and JavaScript. This programming model is similar to the old Windows Forms programming model.
9
Understanding ASP.NET Core 1.0(6/6)
DEMO - TailspinSpyworks
10
Web Technologies(1/17) Core web technologies that are important to know when creating web applications: HTML, CSS, JavaScript, and jQuery.
11
Web Technologies(2/17) HTML
12
Web Technologies(3/17) HTML
HTML5 has been a W3C recommendation since October ( It is already offered by all the major browsers. The things the add-ins do can now be done directly with HTML and JavaScript.
13
Web Technologies(4/17) HTML
HTML5 has been a W3C recommendation since October ( With the features of HTML5, several browser add-ins (such as Flash and Silverlight) are not required anymore Of course, you might still need Flash and Silverlight because not all websites have moved to the new technologies or your users might still be using older browser versions that don’t support HTML5.
14
Web Technologies(5/17) HTML
HTML5 has been a W3C recommendation since October ( 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). A canvas element enables the dynamic use of 2D shapes and images. Video and audio elements make the object element obsolete. With recent additions to the media source ( adaptive streaming is also offered by HTML; Previously this had been an advantage of Silverlight.
15
Web Technologies(6/17) HTML
HTML5 has been a W3C recommendation since October ( 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.
16
Web Technologies(7/17) CSS
Whereas HTML defines the content of web pages, CSS defines the look.
17
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. Whereas HTML defines the content of web pages, CSS defines the look. Nowadays such information is completely removed from HTML and is instead put into a cascading style sheet (CSS).
18
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. You can select an element via its ID or its name, and you can define CSS classes that can be referenced from within the HTML code. With newer versions of CSS, you can define quite complex rules for selecting specific HTML elements.
19
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. This is a collection of CSS and HTML conventions, and you can easily adapt different looks and download ready-to-use templates. You can visit for documentation and basic templates.
20
Web Technologies(11/17) JavaScript and TypeScript
One common misconception about JavaScript is that it has something to do with Java. In fact, only the name is similar because Netscape (the originator of JavaScript) made an agreement with Sun (Sun invented Java) to be allowed to use Java in the name. Nowadays, both of these companies no longer exist. Sun was bought by Oracle, and now Oracle holds the trademark for Java.
21
Web Technologies(12/17) JavaScript and TypeScript.
JavaScript enables accessing the document object model (DOM) from the HTML page. One common misconception about JavaScript is that it has something to do with Java. In fact, only the name is similar because Netscape (the originator of JavaScript) made an agreement with Sun (Sun invented Java) to be allowed to use Java in the name. Nowadays, both of these companies no longer exist. Sun was bought by Oracle, and now Oracle holds the trademark for Java.
22
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. JS makes it possible to change elements dynamically on the client.
23
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. Because other companies are not allowed to use the term Java with their language implementations, the standard has the name ECMAScript. Microsoft’s implementation of JavaScript had the name JScript.
24
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. Because the TypeScript compiler compiles to JavaScript, TypeScript can be used in every place where JavaScript is needed. For more information on TypeScript, check
25
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 ( is a library that abstracts browser differences when accessing DOM elements and reacting to events.
26
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 ( is a library that abstracts browser differences when accessing DOM elements and reacting to events. Angular ( is a library based on the MVC pattern for simplifying development and testing with single-page web applications. Unlike ASP.NET MVC, Angular offers the MVC pattern with client-side code.
27
Using Static Content(1/5)
Demo Empty project Global.json Project.json Debugging Startup file Environment variables launchSettings.json
28
Using Static Content(2/5)
Usually you don’t want to just send simple strings to the client. By default, simple HTML files and other static content can’t be sent. ASP.NET 5 reduces the overhead as much as possible. Even static files are not returned from the server if you do not enable them.
29
Using Static Content(3/5)
In order to enable static files we have to add the extension method UseStaticFiles()
30
Using Static Content(4/5)
In order to enable static files we have to add the extension method UseStaticFiles()
31
Using Static Content(5/5)
Demo Empty project Add UserStaticFiles() Create a static file and see the results
32
Using Dependency Injection with ASP.NET(1/12)
IoC/DI mechanisms Inversion of Control (IoC) is one of those topics that tends to get dismissed by some developers as an advanced concept that they may never need. In the past, developers have had the choice of either rolling out their own code or using one of the many IoC containers to introduce Dependency Injection (DI) in their code. With ASP.NET Core, you will have the choice of using the built-in DI features or making use of existing IoC containers that you may already be familiar with.
33
Using Dependency Injection with ASP.NET(2/12)
IoC/DI mechanisms The idea is to remove the dependencies.
34
Using Dependency Injection with ASP.NET(3/12)
IoC/DI mechanisms Solution: Extract 2 interfaces: one for PolicyLayer and one for MechanismLayer. Add the relations using the interfaces. IoC is a well-known pattern that invents the control of how dependent objects are created within software components. Using DI allows us to implement IoC in our software applications.
35
Using Dependency Injection with ASP.NET(4/12)
IoC/DI mechanisms PROS CONS Helps with adhering to the Dependency Inversion Principle (DIP) DI introduces a learning curve for some developers Allows objects to be easily swapped with replacements DI may require a significant overhaul of existing projects Facilitates the use of the Strategy Design Pattern (SDP) Project timelines may not allow DI Improves the testability of applications Enables loose coupling of software components DIP: High-level modules should not depend on low-level modules. Both should depend on abstractions. B. Abstractions should not depend on details. Details should depend on abstractions.
36
Using Dependency Injection with ASP.NET(5/12)
IoC/DI mechanisms Lifetime management.
37
Using Dependency Injection with ASP.NET(6/12)
IoC/DI mechanisms Transient Transient : A new instance will be created each time the object is needed
38
Using Dependency Injection with ASP.NET(7/12)
IoC/DI mechanisms Transient Scoped Transient : A new instance will be created each time the object is needed. Scoped: A new instance will be created for each web request.
39
Using Dependency Injection with ASP.NET(8/12)
IoC/DI mechanisms Transient Scoped Singleton Transient : A new instance will be created each time the object is needed. Scoped: A new instance will be created for each web request. Singleton: A new instance will be created only once at application startup.
40
Using Dependency Injection with ASP.NET(9/12)
IoC/DI mechanisms Transient Scoped Singleton Instance (special case of Singleton) Transient : A new instance will be created each time the object is needed. Scoped: A new instance will be created for each web request. Singleton: A new instance will be created only once at application startup. Instance : Use AddSingleton() and create an instance yourself.
41
Using Dependency Injection with ASP.NET(10/12)
IoC/DI mechanisms Transient Scoped Singleton Instance (special case of Singleton) There are 2 types of DI.
42
Using Dependency Injection with ASP.NET(11/12)
IoC/DI mechanisms Transient Scoped Singleton Instance (special case of Singleton) Constructor injection There are 2 types of DI.
43
Using Dependency Injection with ASP.NET(11/12)
IoC/DI mechanisms Transient Scoped Singleton Instance (special case of Singleton) Constructor injection Action injection There are 2 types of DI. When you inject a dependency through the constructor, this method is known as constructor injection. If you inject it in an action method, that is known as action injection. You can use either approach in your application.
44
Using Dependency Injection with ASP.NET(12/12)
DEMO Using controllers and views Using IoC and DI Verifying routes Creating midlleware
45
Interview questions(1/1)
46
One more thing…(1/2)
47
“Truth can only be found in one place: the code.”
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
48
Bibliography - By Mike Wasson and Rick Anderson Nagel, Christian. Professional C# 6 and .NET Core 1.0 Chowdhuri, Shahed. ASP.NET Core Essentials The following screenshot shows the creation of HospitalController.cs:
49
Questions Do you have any other questions?
50
Thanks! See you next time!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.