Introduction to .NET Florin Olariu

Slides:



Advertisements
Similar presentations
Castafiore platform Consists or intend to consist of 1.Advanced Web framework 2.Advanced Graph database 3.Designer studio (something like visual basic)
Advertisements

What is HTML5…?. ”…removes the need for plugins” ”…can handle multimedia directly” ”…enables rich, interactive clients” ”…enables advanced visual designs”
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
Web Development in Microsoft Visual Studio Slide 2 Lecture Overview Introduce Visual Studio 2013 Create a first ASP.NET application.
Kashif Jalal CA-240 (072) Web Development Using ASP.NET CA – 240 Kashif Jalal Welcome to week – 2 of…
Introduction to Web Application Architectures Web Application Architectures 18 th March 2005 Bogdan L. Vrusias
Development of mobile applications using PhoneGap and HTML 5
Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development I” Course materials.
WEB DESIGN SOME FOUNDATIONS. SO WHAT IS THIS INTERNET.
UNIT-V The MVC architecture and Struts Framework.
RIA Introduce Comparison among several technology.
DHTML - Introduction Introduction to DHTML, the DOM, JS review.
HTML 5 New Standardization of HTML. I NTRODUCTION HTML5 is The New HTML Standard, New Elements New Attributes Full CSS3 Support Video and Audio 2D/3D.
Lecture 3 – Data Storage with XML+AJAX and MySQL+socket.io
DHTML. What is DHTML?  DHTML is the combination of several built-in browser features in fourth generation browsers that enable a web page to be more.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
JavaScript & jQuery the missing manual Chapter 11
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
NOTE: To change the image on this slide, select the picture and delete it. Then click the Pictures icon in the placeholder to insert your own image. WEB.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Introduction to Programming the WWW I CMSC Summer 2003 Lecture 7.
Building Rich Web Applications with Ajax Linda Dailey Paulson IEEE – Computer, October 05 (Vol.38, No.10) Presented by Jingming Zhang.
Session: 1. © Aptech Ltd. 2Introduction to the Web / Session 1  Explain the evolution of HTML  Explain the page structure used by HTML  List the drawbacks.
ASP (Active Server Pages) by Bülent & Resul. Presentation Outline Introduction What is an ASP file? How does ASP work? What can ASP do? Differences Between.
ASP.NET in Definition: 1.ASP.NET is a web application framework developed and marketed by Microsoft to allow programmers to build dynamic web sites,
Plug-in Architectures Presented by Truc Nguyen. What’s a plug-in? “a type of program that tightly integrates with a larger application to add a special.
8 th Semester, Batch 2009 Department Of Computer Science SSUET.
Introduction to JavaScript MIS 3502, Spring 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 2/2/2016.
JavaScript Invented 1995 Steve, Tony & Sharon. A Scripting Language (A scripting language is a lightweight programming language that supports the writing.
CSCI 3100 Tutorial 5 JavaScript & Ajax Jichuan Zeng Department of Computer Science and Engineering The Chinese University of Hong.
Introduction to JavaScript MIS 3502, Fall 2016 Jeremy Shafer Department of MIS Fox School of Business Temple University 9/29/2016.
Chapter 1 Getting Started with ASP.NET Objectives Why ASP? To get familiar with our IDE (Integrated Development Environment ), Visual Studio. Understand.
Chapter 17 The Need for HTML 5.
Introduction ITEC 420.
DHTML.
Scripting - Client-side vs. Server-side Scripting
Web Technologies Computing Science Thompson Rivers University
Introduction to .NET Florin Olariu
Angular 4 + TypeScript Getting Started
Working with Client-Side Scripting
Application with Cross-Platform GUI
Haritha Dasari Josue Balandrano Coronel -
Lean .NET stack for building modern web apps
By Gary Mandela December 26, 2006
Best Angular 2 interview questions and Answer that have been designed for Angular 2 programmers who are preparing online interviews on Angular 2 interviews question. Visit Website:
Introduction to Silverlight
SharePoint-Hosted Apps and JavaScript
Introduction to JavaScript
Design and Maintenance of Web Applications in J2EE
Cross Platform Charting
Web Development in Microsoft Visual Studio 2013
JavaScript an introduction.
VISUAL BASIC.
A second look at JavaScript
Web Development Using ASP .NET
jQuery The Easy JavaScript Nikolay Chochev Technical Trainer
JQuery with ASP.NET.
Building ASP.NET Applications 2
Web Development Using ASP .NET
Introduction to JavaScript
JavaScript CS 4640 Programming Languages for Web Applications
Web Technologies Computing Science Thompson Rivers University
Introduction to JavaScript & jQuery
Introduce to Angular 6 Present by: Võ Văn Hào
Web Client Side Technologies Raneem Qaddoura
The Future is Now with ASP.NET Core 3.0
JavaScript CS 4640 Programming Languages for Web Applications
Dependency Injection Mechanism
Presentation transcript:

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) 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.

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.

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.

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.

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.

Understanding ASP.NET Core 1.0(6/6) DEMO - TailspinSpyworks

Web Technologies(1/17) Core web technologies that are important to know when creating web applications: HTML, CSS, JavaScript, and jQuery.

Web Technologies(2/17) HTML

Web Technologies(3/17) HTML HTML5 has been a W3C recommendation since October 2014 (http://w3.org/TR/html5) It is already offered by all the major browsers. The things the add-ins do can now be done directly with HTML and JavaScript.

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 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.

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). 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 (http://w3c.github.io/media-source), adaptive streaming is also offered by HTML; Previously this had been an advantage of Silverlight.

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 Whereas HTML defines the content of web pages, CSS defines the look.

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).

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.

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 www.getbootstrap.com for documentation and basic templates.

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.

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.

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.

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.

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 http:// www.typescriptlang.org.

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. Unlike ASP.NET MVC, Angular offers the MVC pattern with client-side code.

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

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.

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 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.

Using Dependency Injection with ASP.NET(2/12) IoC/DI mechanisms The idea is to remove the dependencies.

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.

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.

Using Dependency Injection with ASP.NET(5/12) IoC/DI mechanisms Lifetime management.

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

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.

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.

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.

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.

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.

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.

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)

“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

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 The following screenshot shows the creation of HospitalController.cs:

Questions Do you have any other questions?

Thanks! See you next time! 