Introduction to ASP.NET

Slides:



Advertisements
Similar presentations
Windows Basic and Dynamic Disk Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator Marian Marinov CEO of 1H Ltd.
Advertisements

Hybrid or Native?! Doncho Minkov Telerik Software Academy Senior Technical Trainer
HTML Forms, GET, POST Methods Tran Anh Tuan Edit from Telerik Academy
Amazon S 3, App Engine Blobstore, Google Cloud Storage, Azure Blobs Svetlin Nakov Telerik Software Academy academy.telerik.com.
RPN and Shunting-yard algorithm Ivaylo Kenov Telerik Software Academy academy.telerik.com Technical Assistant
Telerik School Academy ASP.NET MVC.
Shortest paths in edge-weighted digraph Krasin Georgiev Technical University of Sofia g.krasin at gmail com Assistant Professor.
Telerik Software Academy Telerik School Academy.
Asynchronous Programming with C# and WinRT
Unleash the Power of JavaScript Tooling Telerik Software Academy End-to-end JavaScript Applications.
Touch and Gestures with Xamarin Forms
Telerik School Academy ASP.NET MVC.
Character sequences, C-strings and the C++ String class, Working with Strings Learning & Development Team Telerik Software Academy.
Hybrid or Native?! Doncho Minkov Telerik Software Academy Senior Technical Trainer
Done already for your convenience! Telerik School Academy Unity 2D Game Development.
Processing Sequences of Elements Telerik School Academy C# Fundamentals – Part 1.
C# Fundamentals – Part I
NoSQL Concepts, Redis, MongoDB, CouchDB
The Business Plan and the Business Model Margarita Antonova Volunteer Telerik Academy academy.telerik.com Business System Analyst Telerik Corporation.
What are ADTs, STL Intro, vector, list, queue, stack Learning & Development Team Telerik Software Academy.
Making JavaScript code by template! Learning & Development Team Telerik Software Academy.
Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training Who, What, Why?
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Processing Matrices and Multidimensional Tables Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Learning & Development Telerik Software Academy.
Reading and Writing Text Files Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Telerik Software Academy ASP.NET Web Forms.
Classical OOP in JavaScript Classes and stuff Telerik Software Academy
Using Selenium for Mobile Web Testing Powered by KendoUI Telerik QA Academy Atanas Georgiev Senior QA Engineer KendoUI Team.
NoSQL Concepts, Redis, MongoDB, CouchDB Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
New features: classes, generators, iterators, etc. Telerik Academy Plus JavaScript.Next.
Throwing and Catching Exceptions Tran Anh Tuan Edit from Telerik Software Academy
Telerik Software Academy ASP.NET Web Forms.
Private/Public fields, Module, Revealing Module Learning & Development Team Telerik Software Academy.
Building Data-Driven ASP.NET Web Forms Apps Telerik Software Academy ASP.NET Web Forms.
Course Introduction Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Nikolay Kostov Telerik Software Academy Senior Software Developer and Trainer
Telerik Software Academy End-to-end JavaScript Applications.
General and reusable solutions to common problems in software design Vasil Dininski Telerik Software Academy academy.telerik.com Intern at Telerik Academy.
Planning and Tracking Software Quality Yordan Dimitrov Telerik Corporation Team Leader, Team Pulse, Team Leader, Team Pulse, Telerik Corporation,
What you need to know Ivaylo Kenov Telerik Corporation Telerik Academy Student.
Data binding concepts, Bindings in WinJS George Georgiev Telerik Software Academy academy.telerik.com Technical Trainer itgeorge.net.
Pavel Kolev Telerik Software Academy Senior.Net Developer and Trainer
Objects, Properties, Primitive and Reference Types Learning & Development Team Telerik Software Academy.
When and How to Refactor? Refactoring Patterns Alexander Vakrilov Telerik Corporation Senior Developer and Team Leader.
Free Training and Job for Software Engineers Svetlin Nakov, PhD Manager Technical Training Telerik Corp. Telerik Software Academy.
Free Training and Job for Software Engineers Svetlin Nakov, PhD Manager Technical Training Telerik Corp. Telerik Software Academy.
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Doing the Canvas the "easy way"! Learning & Development Telerik Software Academy.
Creating and Running Your First C# Program Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Course Overview Doncho Minkov Telerik Software Academy Technical Trainer
Data Types, Primitive Types in C++, Variables – Declaration, Initialization, Scope Telerik Software Academy academy.telerik.com Learning and Development.
The past, the present, the future Learning & Development Team Telerik Software Academy.
Learn to Design Error Steady Code Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Connecting, Queries, Best Practices Tran Anh Tuan Edit from Telerik Software Academy
Processing Sequences of Elements Telerik Software Academy C# Fundamentals – Part 2.
Telerik JavaScript Framework Telerik Software Academy Hybrid Mobile Applications.
Telerik Software Academy Databases.
Things start to get serious Telerik Software Academy JavaScript OOP.
Learning & Development Mobile apps for iPhone & iPad.
Processing Matrices and Multidimensional Tables Telerik Software Academy C# Fundamentals – Part 2.
Nikolay Kostov Telerik Software Academy academy.telerik.com Team Lead, Senior Developer and Trainer
ASP.NET Web API Telerik Software Academy
Functions and Function Expressions Closures, Function Scope, Nested Functions Telerik Software Academy
Implementing Control Logic in C# Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical trainer
Inheritance, Abstraction, Encapsulation, Polymorphism Telerik Software Academy Mobile apps for iPhone & iPad.
Mocking tools for easier unit testing Telerik Software Academy High Quality Code.
What why and how? Telerik School Academy Unity 2D Game Development.
Windows Security Model Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator
Presentation transcript:

Introduction to ASP.NET ASP.NET, Architecture, Web Forms, MVC, Web API Svetlin Nakov Technical Trainer www.nakov.com Telerik Software Academy academy.telerik.com

Table of Contents Introduction to ASP.NET ASP.NET App Structure History, Components, Frameworks ASP.NET App Structure Typical Files and Folders in ASP.NET Projects ASP.NET App Lifecycle Application Lifecycle, HTTP Modules, HTTP Handlers, Events, Controllers, Pages, … ASP.NET Common Concepts Classes & Namespaces, Web Sites & Web Apps

Introduction to ASP.NET * Introduction to ASP.NET (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

History of ASP.NET At the beginning of Internet (up to 1997) CGI, ISAPI (for C, C++), PHP Classic / Legacy ASP (1997-2002) Based on VB Script, COM, ADO ASP.NET 1.1 (2002-2005) – based on .NET 1.1 ASP.NET 2.0 (2005-2007) – based on .NET 2.0 ASP.NET 3.5 (2007-2009) – LINQ to SQL, MVC ASP.NET 4.0 (2010) – Entity Framework, MVC ASP.NET 4.5 (2012) – ASP.NET One ASP.NET

What is ASP.NET? ASP.NET is a stack of technologies to create web sites, web services and web applications

ASP.NET: Web Forms vs. MVC ASP.NET has two major frameworks for Web application development ASP.NET Web Forms (read more) The traditional component-based approach Mixes the presentation and presentation logic ASP.NET MVC (read more) Modern approach, more clear and flexible MVC architecture, like Ruby-on-Rails and Django Testable (test the controllers)

ASP.NET: Web Pages, Web API ASP.NET Web Pages (read more) Lightweight framework to combine server code with HTML to create dynamic web content Like PHP: mix HTML code with C# code Uses the "Razor" templating engine ASP.NET Web API (read more) Framework for building RESTful Web services Write C# code to handle HTTP requests in REST style (GET / POST / PUT / DELETE requests) Return JSON / XML as result

ASP.NET: SPA, SignalR Single Page Applications (SPA) (read more) A framework for SPA with JS and REST Write a HTML5 single page apps with jQuery / Knockout.js / other JS client-side framework Client HTML5 code consumes Web API services SignalR (read more) Real-time communication between client (JS) and server (C#) over HTTP through Web Sockets Server C# code can invoke JS functions at the client Client JS code can invoke C# methods at the server

Simple Web Forms App Live Demo

Simple MVC App Live Demo

Typical Application Structure in ASP.NET ASP.NET App Structure Typical Application Structure in ASP.NET

ASP.NET App Structure App_Start App_Data Web.config Global.asax Content and Content\themes img, Scripts Bundle.config / BundleConfig.cs Models / Views / Controllers Site.Master / Site.Mobile.Master

App_Start The App_Start folder BundleConfig.cs (read more) Holds global configuration logic Loaded once, at application start-up BundleConfig.cs (read more) Combines all CSS / JS files in a single bundle FilterConfig.cs (read more) Configures filters in MVC / Web API apps Configures pre-action and post-action behavior to the controller's action methods

App_Start (2) RouteConfig.cs (read more) Configures URL patterns and their handlers Maps user-friendly URLs to certain page / controller IdentityConfig.cs / Startup.Auth.cs Configures the membership authentication Users, roles, login, logout, user management OAuth login (read more) Facebook / Twitter / Microsoft / Google login

App_Data The App_Data directory holds the local data files of the Web application E.g. MyWebApp.mdf + MyWebApp.ldf E.g. Countries.xml The SQL Server "Local DB" (read more) Local .mdf + .ldb files, attached at startup SQL Server process started on demand Database created on demand (if missing) Great for development and testing

Web.config Web.config is web app's configuration file Holds settings like DB connection strings, HTTP handlers, modules, assembly bindings Can hold custom application settings, e.g. credentials for external services Changes in Web.config do not require restart You may have several Web.config files One global for the application Several for different folder in the application

Web.config (2) Web.config inherits from the global Web.config and from machine.config Global settings for all applications on the server Web.Debug.config Local settings for debugging E.g. local database instance for testing Web.Release.config Production settings for real world deployment C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config

Web.config – Example <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <section name="entityFramework" requirePermission="false" type=" System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> </configSections> <connectionStrings> <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\ aspnetDB.mdf;Initial Catalog=aspnet;Integrated Security=True" /> </connectionStrings> <appSettings> <add key="ClientValidationEnabled" value="true" /> … </appSettings> <system.web> <compilation debug="true" targetFramework="4.5" /> </system.web> <entityFramework> </entityFramework> </configuration>

Global.asax Global.asax defines the HTTP application Defines global application events like Application_Start Application_BeginRequest Application_EndRequest Application_Error … Typically invokes BundleConfig, RouteConfig, FilterConfig, etc.

ASP.NET App Lifecycle Application Lifecycle, HTTP Modules, Handlers, Events, Controllers, Pages, …

ASP.NET App Lifecycle MHPM == Module, Handler, Page Events, Module Events * Source: http://www.codeproject.com/Articles/73728/ (by Shivprasad Koirala)

ASP.NET App Lifecycle (2) * Source: http://www.codeproject.com/Articles/73728/

ASP.NET App Lifecycle (3) * Source: http://www.codeproject.com/Articles/73728/

ASP.NET App Lifecycle (4) * Source: http://www.codeproject.com/Articles/73728/

ASP.NET App Lifecycle (5) * Source: http://www.codeproject.com/Articles/73728/

ASP.NET App Lifecycle (6) * Source: http://www.codeproject.com/Articles/73728/

Application Lifecycle Events HttpApplication have a complex pipeline to the process HTTP requests (read more) BeginRequest AuthenticateRequest AuthorizeRequest AcquireRequestState ProcessRequest ReleaseRequestState EndRequest

App Lifecycle Events Live Demo

HTTP Handlers A "HTTP handler" is a process / C# code that responses to HTTP requests Sample HTTP handler in C#: Handler registration in Web.config: public class NakovHttpHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.Write("I am а HTTP handler."); } public bool IsReusable { get { return false; } } } <configuration><system.webServer><handlers> <add verb="*" path="*.nakov" name="Nakov's HTTP handler" type="NakovHttpHandler"/> </handlers></system.webServer></configuration>

Writing a HTTP Handler Live Demo

HTTP Modules HTTP modules can customize requests for resources that are serviced by ASP.NET It can intercept all HTTP requests and apply a custom logic Steps to create an HTTP Module Implement the IHttpModule interface Subscribe to events you want to intercept, e.g. HttpApplication.BeginRequest Register the HTTP module in Web.config in the <modules> section

Writing a HTTP Module Live Demo

ASP.NET Common Concepts Major Classes, Namespaces, Web Sites, Web Apps

ASP.NET Namespaces Major ASP.NET namespaces System.Web System.Web.Mvc Web application main classes like HttpApplication, HttpContext, HttpRequest, HttpResponse, HttpSessionState, … System.Web.Mvc MVC classes and framework components System.Web.UI Web Forms UI controls (like Button and Label)

ASP.NET Classes HttpApplication HttpContext HttpRequest HttpResponse Base class for the ASP.NET Web apps (inherited in Global.asax) HttpContext Encapsulates all HTTP-specific information about an individual HTTP request HttpRequest Encapsulates an HTTP request HttpResponse Encapsulates an HTTP response

Web Site vs. Web Application Web Sites in VS No project file (.csproj / .sln) Code compiled dynamically at the Web server Can be precompiled (into multiple assemblies) Web Apps in VS Have project file (like any C# project) Compilation produces an assembly: bin\*.dll Web apps are recommended (read more)

ASP.NET Introduction http://academy.telerik.com

Free Trainings @ Telerik Academy C# Programming @ Telerik Academy csharpfundamentals.telerik.com Telerik Software Academy academy.telerik.com Telerik Academy @ Facebook facebook.com/TelerikAcademy Telerik Software Academy Forums forums.academy.telerik.com

Exercises Create and run few Web applications in Visual Studio to play with ASP.NET, compile and run them: ASP.NET Web Forms application ASP.NET MVC application ASP.NET Web API application ASP.NET Single Page application (SPA) Write a simple application to sum numbers in ASP.NET Web Forms and ASP.NET MVC. Submit the code only (without the NuGet packages). * Write an HTTP handler that accepts a text as HTTP GET or POST request and returns as a result the text as PNG image. Map it to process *.img requests.