Tuesday, November 3, 2015

Module I ASP.NET 4.5 Lecture 1

Browser Server Communication 

1- User types URL ()/Clicks Hyper link etc, Browser Sends request to that address using Http
2- If the server is active it accepts the request
3- If the requested resource is HTML or image the server reads the file from local drive and sends it to browser
4- If the resource is a dynamic file such as aspx, the server checks Application Mapping/Handler Mapping to determine the piece of code required to execute this file.
5- The file is then execute and output is sent to browser.


Contents of ASPX File

An ASPX file contains 
- Static HTML, Javascript or CSS. These are sent directly to the browser
- ASP.NET Server control,. These controls are placed in your ASPX page and when they are processed, they emit HTML that is inserted in the page
- Programming Code, You can embed code, like Visual Basic .NET or C#, directly in a page. In addition, you can place code in a separate code file (Code Beside/Code Behind). This code can be executed by runtime automatically or in response to a particular event like Button_Click or Page_Load 

New Project Vs New Web Site

Visual Studio allows you to choose between a website and a web application
Web Site Projects 
- Suitable when a single person is doing work
- It is made of a folder in which a number of files are stored. All files in the folder are considered to be part of project
- Deployment is easy as it involves simply making a folder available to webserver
- Updates can be made by simply copying the file on the server

Web Application Projects 
- Suitable when a team of people are working on a single web site 
- Is compatible with tools that manages versioning like Team Foundation Server
- Maintains a proj file which records the contents of the application and developers have more control over compilation and deployment
- Has support for Technologies like MVC and WebAPI


Four Main Development Frameworks Supported by ASP.NET

ASP.NET Web Forms
- Allows declarative and control-based programming using Microsoft Windows Forms (WinForms) and WPF/XAML/Silverlight. 
- WYSIWYG (What you see is what you get) designer-driven development model
- Suitable for rapid application development (RAD) - Enables programmers to develop web applications without getting command on other web related technologies like HTML and javaScript

ASP.NET MVC
Development is based on patterns and principles like testdriven development, separation of concerns, inversion of control (IoC), and dependency injection (DI). 
Encourages separating the business logic layer of a web application from its presentation layer. 

ASP.NET Web Pages
Development is done in similar way as it is done in other web technologies like PHP. 
HTML pages are created and then server-based code is added to the page in order to dynamically control how that markup is rendered. 
A lightweight framework 

ASP.NET Single Page Applications (SPA)
Applications that include significant client-side interactions using HTML 5, CSS 3 and JavaScript. 
Uses knockout.js and ASP.NET Web API.  community-created SPA templates are also available for download


Starting With ASP.NET 

Getting Started with Basics
- Create a new Web Site by Selecting File -> New Web Site 
- Choose Empty Website from List of Templates
- Specify a name for the site and Press Save
- Select Website -> Add New Item 
- In the Add New Item Dialog, Choose Visual C#, select Webform and then press add

As a result of the above, you can find a new file added under the website in Solution Explorer

Designing the page using WYSIWYG (Design View)
- Select Design from the bottom
- Select View -> Toolbars and make sure Formatting toolbar is selected. 
- Write any text on the page and use "B" or "I" on the formattint toolbar to add and tags

The Formatting toolbar can be used to add some basic HTML tags to the page. A list of tags is also provided in block format dropdown from which you can choose Headings, List and other HTML elements

The formatting toolbar provides similar interface as that of MS Word but adds HTML and CSS in the source of the page. 

The Style of Bullets and numbering can be modified using the Format -> Bullets and Numbering menu

Table can be inserted using  Table -> Insert Table. This will cause the "Insert Table" Dialog to be opened where the programmer can specify the Rows, columns and other settings 

If the borders of the table are not visible, select Visible Borders from View -> Visual Aids