Date post: | 13-Dec-2014 |
Category: |
Documents |
Upload: | adil-mughal |
View: | 4,842 times |
Download: | 2 times |
Web Programming Conceptsusing
ASP.NET
Adil Ahmed Mughal
Namrah Arif
3rd April, 2010
NED University of Engineering and Technology
Speaker(s)
• Adil Ahmed Mughal
• Development Executive at Telenor Pakistan
• Microsoft Most Valuable Professional
• Microsoft Certified Professional
• INETA, User Group Leader
• I blog at http://www.adilmughal.com
• Author of few articles on CodeProject.com
11
Speaker(s)
• Namrah Arif
• Software Engineer at Folio3
• Graduated from NEDUET (CIS Dept.) in 2009
• Served as head Volunteer of DevNext at
NEDUET in 2009
• Active volunteer of DevNext and
Emerging .NET Devs User groups
Agenda
• Background
• Web Fundamentals– HTTP Request
– Static and Dynamics Sites
– HTTP Forms
– Role of Web Server
• ASP.NET– ASP.NET Page Life Cycle
– Client Side vs. Server Side
– Understanding Submit vs. PostBack
– State Management and View State
Pre-requisite
• Some working knowledge of Object Oriented
Programming Language such as C#, VB.NET or
Managed C++
• Basic familiarity with Web and ASP.NET
• Development Tools:– .NET Framework 3.5+
– Visual Web Developer or Visual Studio 2008 +
Web Fundamentals
• HTTP Requests– The communication mechanism by which Web browsers talk to
Web sites – As a connection protocol, HTTP is built around several basic
commands– GET, HEAD, POST– HTTP is Stateless Protocol
Web Browser(Client)
Web Site(Server)
HTTP GET Request
HTML to be rendered by browser
Sample GET Command
GET http://www.adilmughal.com HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, ... , */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; ... .NET CLR 3.0.04506.30)
Host: localhost:80
Connection: Keep-Alive
Sample Response
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
X-Powered-By: ASP.NET
Date: Thu, 01 Nov 2007 23:44:04 GMT
Content-Type: text/html
Accept-Ranges: bytes
Last-Modified: Mon, 22 Oct 2007 21:54:20 GMT
ETag: "04e9ace185fc51:bb6"
Content-Length: 130
<html>
<body>
<h1> Hello World </h1>
Nothing really showing here yet, except some HTML...
</body>
</html>
DEMOWeb Request using .NET (With out using Browser)
Web Fundamentals
• Static Pages– The earliest web sites were built primarily using static HTML
pages.– HTML eventually evolved to be capable of much more
• HTML Forms– Notify browser that a section of HTML includes tags representing
controls– The contents of the form will be “posted back” to the server for
processing.
Web Fundamentals
• HTTP Requests– GET vs. POST
DEMOHTML Forms – GET Vs. POST
Web Browser(Client) Web Site
(Server)
GET http://www.abc.com
HTML to be rendered by browser
POST http://www.abc.com
HTML to be rendered by browser
Web Fundamentals
• Role of Web Server– A program on server that monitors port 80 for incoming HTTP
Requests
– On the Microsoft platform, IIS is the watchdog intercepting HTTP requests from port 80—the normal inbound port for HTTP requests
Web Browser(Client)
Web Site(Server)
HTTP GET Request
HTML to be rendered by browser
IIS(Web
Server)
Web Fundamentals
• Static and Dynamic Web Pages
“Dynamic means capable of action and/or change, while
Static means fixed”
• Static Web Pages:– The server where the page is stored returns the HTML
document to the user's computer and the browser displays it– The user may interact with the document through clicking
available links, or a small program (an applet) may be activated, but the document has no capacity to return information that is not pre-formatted
Web Fundamentals
• Dynamic Web Pages:– The user can make requests (often through a form) for data
contained in a database on the server that will be assembled on the fly
– The request is relayed to the server using an intermediary, such as an Active Server Page (ASP) script embedded in the page's HTML. The intermediary tells the server what information to return
Web Fundamentals
●What's the difference?– Static pages are those that send exactly the same response to
every request– Dynamic pages can customize the response on the server to
offer personalization based on cookies and information it can get from the visitor.
IMPORTANT!!! Flash and Shockwave presentations are also classed as static content; despite the fact that user interaction can lead to different ways of presenting the same data, everyone will download the same file from the server
ASP.NET
• Web application development framework by Microsoft to easily create dynamic websites
•
• Built on top of CLR allowing programmer to write ASP.NET code using any .NET Languages (such as C#, VB.NET etc.)
• Main advantage is Rapid Application Development
• Works on Code behind model
.NET Framework Overview
Operating System/Hardware
Internet Information Services
.NET Runtime (CLR)
ASP.NET
Data, LINQ, & XML
System
Communications & Workflow
Windows Presentation Foundation
Managed Application
.NET Class Libraries
DEMOSimple ASP.NET Web Application
Introduction to ASP.NET Pages
HTTP Handler
IISClient
Browser
DEMOASP.NET Page Life Cycle
ASP.NET
• Client Side vs Server Side– Client side is what's happening on your computer in your
browser. It has nothing to do with the server, or ASP or ASPX pages, or IIS, or the database.
– JavaScript in a web page would be an example of something client side. You don't need the server to help with the functionality of the script.
– when a web page is sitting in your browser after it has been processed by the server and sent "over the wire", there is absolutely no further connection with the server at this point.
– Client side scripting is usually done in VBScript or JavaScript. Since the code is included in the HTML page, it also poses as a possible security hazard for the client computer.
ASP.NET
– Server side is when the server is being used to process something. Script or code that is run on the server does not appear on or in the web page that is sent to your browser -- the web page that your browser receives is only the result of the script or database code or processing that happened on the server.
– Server side scripting means that all the script will be executed by the server and interpreted as needed. Client side scripting means that the script will be executed immediately in the browser such as form field validation, clock, email validation, etc.
DEMOSubmit Vs. PostBack
State Management
• The problem of state– HTTP is a stateless protocol
– Traditional desktop applications have a portion of memory allocated
– Web applications are all together different
– ASP.NET facilitates programmers by creating an illusion of maintaining state using ViewState and other techniques
DEMOViewState
Web Forms vs. MVC Framework
• Common Web Presentation Patterns– MVC
• Ruby on Rails
• ASP.NET MVC
• MonoRail
• Others…– Web forms– Other patterns
• MVP
• MVVM
•
Web Forms
• Tooling/designer• Postbacks• Event driven• HTML forms and viewstate• Controls abstraction• 3rd party component model• Rapid development• Declarative syntax• SharePoint use Web Forms
ASP.NET MVC
• Full control over markup• Lightweight views/no Codebehind• Separation of concerns • Testing/TDD• Pluggable view engines• RESTful• No postbacks • No viewstate
Making a choice
• Personal choice• Internet versus intranet• Control over markup• Familiarity with patterns• Gradual progression• RAD controls• SharePoint• They can be used together!
THANK YOU!
Adil Ahmed Mughal
Namrah Arif
3rd April, 2010
Q & A
Useful Links
• DevNext User Group Blog• http://www.DevNextUg.org
• Adil’s Weblog• http://www.adilmughal.com
• DevNext Facebook Page• http://www.facebook.com/DevNext