presentation on asp.net

Upload: tanmoyguha

Post on 09-Apr-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/8/2019 Presentation on Asp.Net

    1/31

  • 8/8/2019 Presentation on Asp.Net

    2/31

    HomeHome

    .NET Framework 3

    Introduction to Asp.Net 4

    Overview 5

    Asp.Net Features 6

    Asp.Net Page structure 9 Event Handlers 12

    Web Form Page Life Cycle 13

    Script Section 14

    HTTP Handlers 17

    Server Controls 18

    Web Server Controls 19Working with Web Objects 21

    Web Services 27

    A Word of Thanks 29

    Subject Slide No.

  • 8/8/2019 Presentation on Asp.Net

    3/31

    HomeHome

    The Way in which Programs are Executed in .NET

    .NET Class

    Library

    Compiled into assembly

    Common Language Runtime(CLR)

    Compiled into native code

    Executes

    User

    Welcome

    DLL

    (in MSIL)

    .NET Application code is compiled into Microsoft Intermediate

    Language (MSIL) and stored into a file called DLL.Applicationsthat run under Common Language Runtime (CLR an execution

    engine ) are called managed Code as it providesJIT. At run

    time the Assembly is compiled to its final state by the CLR.While running the CLR provides memory management,

    type-safety checks, and other run-time tasks for the Application.

    1

  • 8/8/2019 Presentation on Asp.Net

    4/31

    HomeHomeINTRODUCTION TO ASP.NETINTRODUCTION TO ASP.NET

    ASP.NET is a part of the Microsoft .NET strategy

    for Web development. It is a Web development platform that providesthe services necessary for developers to build

    enterprise-classWeb applications.

    It applies an object-oriented approach to dynamic

    Web applications. ASP.NET Web applications are an optimal solution

    for managing large-scale business applications.

    ASP.NET Web applications can be deployed on

    the Internet or on an intranet.

    2

  • 8/8/2019 Presentation on Asp.Net

    5/31

    HomeHome

    Welc e

    Server

    Resources :

    Welcome.aspx

    /img

    Data Store

    .

    .

    .

    Executable

    Server

    Returns Response3

    Receives

    Request1

    Co posesResponse

    2

    An Asp. Net Web application response fro server resources

    3

  • 8/8/2019 Presentation on Asp.Net

    6/31

    HomeHome ASP.NET FEATURESASP.NET FEATURES

    y

    Supports multiple programming languages

    ASP.NET

    VB.NET C# JScript

    Other

    languages

    supports

    Web Application

    4

  • 8/8/2019 Presentation on Asp.Net

    7/31

    HomeHomeADVANTAGES OF ASP.NETADVANTAGES OF ASP.NET

    A new development interface underVisual

    Studio.NET. Separation of code and presentation logic for better

    understanding and maintenance. Extensive language support likeVisual Basic .NET, C#,Jscript

    and ADO.NET.

    Greater scalability.

    Extensive security support. Efficient state management.

    Improved data access using ADO.NET. Optimizes the performances of request processing by

    providing extensive caching support. Easy deployment of applications.

    5

  • 8/8/2019 Presentation on Asp.Net

    8/31

    HomeHome

    Internet Information Services (IIS)

    Server resources:

    Welcome.aspx

    FindTitles.aspxSystem.aspx

    /imgPubs Database

    .

    .

    .

    WelcomeWeb.config

    Style Sheet(CSS)

    IIS ReturnsResponse

    3 Application composes

    Response2

    IISStarts Application1

    Asp. Net Web application parts interaction on a Web Server

    6

  • 8/8/2019 Presentation on Asp.Net

    9/31

    HomeHome

    y Page files are text files with an extension .aspx or .ascx

    y Implements application logic using server-side code

    y

    Presents information to the user in any browser as they arecompatible with any browser or mobile device

    y Compatible with any language supported by the .NET CLR

    y

    Uses extensive controls to create rich user interfaces quickly

    y Supported in Visual Studio with powerful rapid application

    development tools for designing and programming user forms

    7

  • 8/8/2019 Presentation on Asp.Net

    10/31

    HomeHomeASP.NET PAGESASP.NET PAGES

    WebForm.aspx WebForm.aspx.cs

    WebForm

    Visual component(Usually ContainsHTML and JScript)

    Logic (codebehind)

    User interface in thebrowserBoth files together make up a WebForm

    Static Text and Controls

    8

  • 8/8/2019 Presentation on Asp.Net

    11/31

    HomeHomePAGE DIRECTIVESPAGE DIRECTIVES

    y @Page: Defines page-specific attributes used by the ASP.NET page parser

    and compiler. Can be included only in .aspx files.

    y @Control: Defines control-specific attributes used by the ASP.NET

    page parser and compiler. Can be included only in .ascx files (user controls).

    y @Import: Explicitly imports a namespace into a page or user control.

    y @Implements: Declaratively indicates that a page or user control

    implements a specified .NET Framework interface.

    y @Register: Associates aliases with namespaces and class names,

    allowing user controls and custom server controls to be rendered when

    included in a requested page or user control

    y @Assembly: Declaratively links an assembly to the current page or user

    control.

    y @OutputCache: Declaratively controls the output caching policies of a

    page or user control.

    y @Reference: Declaratively links a page or user control to the current

    page or user control.

    9

  • 8/8/2019 Presentation on Asp.Net

    12/31

    HomeHomeEVENT HANDLERSEVENT HANDLERS

    y An Event handler is a subroutine that

    executes code for a given event.

    y Events are raised during each stage of a

    Web Form processing.

    y The event handler that corresponds to

    the raised event runs.

    y They provide entry points that allow youto update the contents of the Web Forms

    page.

    10

  • 8/8/2019 Presentation on Asp.Net

    13/31

    HomeHomeWEB FORM PAGE LIFE CYCLEWEB FORM PAGE LIFE CYCLE

    Stage Event RaisedPage_Init

    Page Load

    Validate

    Form event handler

    Page_Unload

    Page_PreRender

    PageInitialization

    User CodeInitialization

    Validation

    EventHandling

    Before Pagerendering

    Cleanup

    Some events are fired automatically by the page duringsome specific stages of page processing. Others that

    are associated with server controls are triggeredon the client but are fired and handled on the server.

    11

  • 8/8/2019 Presentation on Asp.Net

    14/31

    HomeHomeSCRIPT SECTIONSCRIPT SECTION

    Script section

    Server-side script Client-side script

    Executed by the server Executed by the browser

    C#

    VB

    Jscript

    12

  • 8/8/2019 Presentation on Asp.Net

    15/31

    HomeHomeCLIENT SIDE SCRIPTCLIENT SIDE SCRIPT

    y They are part of a page and are sent to

    the browser which executes them when a

    user requests the page.

    y Typically used to:

    Change the appearance of the page when it is

    loaded in the browser

    Perform validation on the data entered by the

    user in a form

    Display relevant information in the browser

    13

  • 8/8/2019 Presentation on Asp.Net

    16/31

    HomeHomeSERVER SIDE SCRIPTINGSERVER SIDE SCRIPTING

    y Code can be contained in either server-side code declaration blocks or

    render blocks .

    y

    ASP.NET supports server-side code in anylanguage that targets the runtime.

    y Server-side code declaration blocks must

    have the runat="server" attribute.

    y The src attribute specifies the path andfilename of a script file to load .

    14

  • 8/8/2019 Presentation on Asp.Net

    17/31

    HomeHome

    y Every request in ASP.NET is processed by anHttpHandler

    For example,ASPX pages are handled by the default

    ASPX Page HttpHandler.

    y You can create your own HttpHandler to rendercontent based on the requesty Handlers process the incoming request andgenerate the response output.

    y Can be directly plugged in IIS7 (no moreregistering extensions to the ISAPI ASP.NET DLL).

    HTTP HANDLERSHTTP HANDLERS

    HttpModules are Similar to ISAPI FiltersThey are built using .NETThe Integrate with the ASP.NET Request Pipeline

    oThe Pipeline is over 20 events that fire duringthe processing of a request.

    Used to Catch the Request and React as needed.oURL Rewriting

    oSecurity

    oLogging

    HTTP MODULESHTTP MODULES

    15

  • 8/8/2019 Presentation on Asp.Net

    18/31

    HomeHomeSERVER CONTROLSSERVER CONTROLS

    HTML controls

    1. Flexible controls.2. Not many features.

    3. Used when the form runs in the clientside and user does not need many

    features to be incorporated.4. Useful when porting ASP applications

    to ASP.NET.

    Web controls

    1. Rich features that enable programmingof controls

    2. Large variety of controls present.

    3. Used when the form runsin the server side.4. Better functionality to handle data

    stored in the database5. Useful in visual design environments.

    16

  • 8/8/2019 Presentation on Asp.Net

    19/31

    HomeHome WEB SERVER CONTROLSWEB SERVER CONTROLS

    ASP.NET provides a set of object-oriented GUIcomponents known as Web Server Controls todesign and develop a web application apart from theHTML controls generally used to design webapplications.

    HTML Controls include Htmlform, HtmlImage, HtmlInputfile,etc.

    All ASP.NET web server controls derive fromSystem.Web.UI.WebControls namespace.

    The ID property can be found in all web servercontrols and is used to give a name to the control beingused in the form for referring it in code and identifying ituniquely among all the controls used in the web form.

    17

  • 8/8/2019 Presentation on Asp.Net

    20/31

    HomeHome WEB SERVER CONTROLSWEB SERVER CONTROLS

    y

    The AutoPostBack property can be found in all web servercontrols which post back their data to the server when the

    form is posted or when a button is clicked.

    y The EnableViewState property can be found in all web server

    controls and is used to define whether a controls ViewState or

    the present value it contains is to be retained in the controlafter the form is posted back to the server.

    y Web Server Controls can be classified as:

    Text Entry Controls

    Control Transfer Controls

    Selection Controls Container Controls

    y Rich or Special Controls are a set of specialty controls that

    reside in the System.Web.UI.WebControls namespace, and

    used for a particular task, E.g. : AdRotator, Calendar, etc..

    18

  • 8/8/2019 Presentation on Asp.Net

    21/31

    HomeHome

    y NAMESPACES

    y USING THE REQUEST OBJECT

    y USING THE RESPONSE OBJECT

    y RETAINING VALUE OF VARIABLES

    y SESSION AND APPLICATION STATE VARIABLES

    y CONFIGURATION FILES

    y WEB.CONFIG FILE

    WORKING WITH WEB OBJECTSWORKING WITH WEB OBJECTS

    19

  • 8/8/2019 Presentation on Asp.Net

    22/31

    HomeHome

    Namespaces :

    System.Web : The Application, Browser, Cache, Cookies, Exception,Request,Response, Server, andTrace Objects.Use these Classes in mostWeb

    Programming tasks.The Application object defined in Global.asax is based onthe Application class.

    System.Web.SessionState : The Session object.These classes are used to

    retrieve and save items in Session state.

    System.Web.Services : TheWebService object.These classes are referred tocreate and use Web Services.

    System.Web.UI : The Page and Control objects.These classes are used inWeb form to create and control an applications user interface.Web forms arebased on the Page Class.

    Namespaces are a way of organizing code. They provide protection from

    conflicting names, sometimes called namespace collisions. This protection isespecially necessary in large projects in which it is very easy for two items

    to accidentally have the same name. By organizing your code into namespaces,

    you reduce the chance of these conflicts.

    COLLECTION OF SIMILAR CLASSESNAMESPACES

    TOPIC

    HOME

    20

    WORKING WITH WEB OBJECTSWORKING WITH WEB OBJECTS

  • 8/8/2019 Presentation on Asp.Net

    23/31

    HomeHome

    The Page Object Controls your Applications userInterface. The Page object has properties and methods

    that provide access to other objects in the userinterface.

    The Page base class provides the core methods andproperties that you use frequently when programming

    Web forms.

    Cache

    Controls

    Page

    Request

    Response

    Server

    Session

    Trace

    WORKING WITH WEB OBJECTSWORKING WITH WEB OBJECTS

    20

  • 8/8/2019 Presentation on Asp.Net

    24/31

    HomeHome

    y The Request Object contains the information sent by theclient browser when a page is requested from the application.The Request has properties and methods that provide accessto other objects that make up the request, as shown in thefigure.

    y The HttpRequest object encapsulates information that theclient provides when requesting a page or when submitting aform.

    WORKING WITH WEB OBJECTSWORKING WITH WEB OBJECTS

    USING THE REQUEST OBJECT

    Request

    Browser

    Client Certificates

    Cookies

    Files

    InputStream

    Determine the Capabilities of theBrowser making the request.

    Browser properties provide thebrowser version number, determine

    if it supports cookies, and supply

    other Information.

    Authenticate the Client

    Get Information from the client inthe form ofCookies

    Get Files that are Uploaded by theClient

    Read and Write to the raw data sentin the request

    TOPIC

    HOME

    21

  • 8/8/2019 Presentation on Asp.Net

    25/31

  • 8/8/2019 Presentation on Asp.Net

    26/31

    HomeHome

    y Web forms are created and destroyed each time a client browsermakes a request. Because of this characteristic, variables declaredwithin a Web form do not retain their value after a page isdisplayed. To solve this problem,Asp. Net provides the followingways to retain variable between requests:

    WORKING WITH WEB OBJECTSWORKING WITH WEB OBJECTS

    Context.Handlerobject : This object is used to retrieve public membersof one Web forms class from a subsequently displayed Web form.Query strings : This is used to pass information between requests andresponses as part of the Web address. They are visible to the user, so they

    should not contain secure information such as passwords.

    Cookies : They are used to store small amounts of Information on aClient. Client might refuse cookies, so the code has to anticipate that

    possibility.

    View State :ASP. Net stores items added to a pages ViewState propertyas hidden fields on the page.Session state : The Session state variables are used to store items thatyou want to keep local to the current session ( single user ).

    Application state : The Application state variables to store items that youwant to be available to all users of the application.

    TOPIC

    HOME

    23

  • 8/8/2019 Presentation on Asp.Net

    27/31

    HomeHomeWORKING WITH WEB OBJECTSWORKING WITH WEB OBJECTS

    Application Level

    Session Level

    String ourname = nobel";Response.Write ("Welcome " +ourname);

    Global.asax

    * Stores event handlers for all events

    * Stored in the root directory of the application

    * Its location defines the boundary for the application

    * Contains configuration settings for allapplications.

    TOPIC

    HOME

    24

  • 8/8/2019 Presentation on Asp.Net

    28/31

    HomeHome

    y Application and Session state variables are created on

    the fly, without variable name or type checking. We

    should limit the access points to these variables.

    y Maintaining Session state affects performance. Session

    state can be turned off at the application and pagelevels.

    y Application state variables are available throughout the

    current process, but not across processes. If an

    application is scaled to run on multiple servers or on

    multiple processors within a server, each process has its ownApplication state.

    y The Web applications boundaries determine the scope of

    the Application state

    WORKING WITH WEB OBJECTSWORKING WITH WEB OBJECTS

    SESSION & APPLICATION STATE VARIABLESSession Management can be done in3 ways :

    Inproc

    StateServer

    SqlServer

    InProc is the default and easiestmethod. Its a good entry-level and yet

    still powerful way to maintain state. Itsalso very performant. Data in the

    session is stored in the same memory

    space as the application.

    The StateServer is a Windows servicesthat operates independently of the web

    sites app domain. Objects do require

    serialization, however, performance isvery good. The state server can live onone of the web servers, and other web

    servers can point to it so the client canconnect to multiple servers and receive

    the same state.

    The most powerful comes from SQLServer as a state server. It involves a bit of

    overhead due to serialization and dataretrieval, however, the performance is still

    quite good. Many customers already havelarge/redundant SQL deployments, soleveraging this infrastructure is anadvantage.

    TOPIC

    HOME

    25

  • 8/8/2019 Presentation on Asp.Net

    29/31

    HomeHomeWORKING WITH WEB OBJECTSWORKING WITH WEB OBJECTS

    Type of Tag Rule

    Tag and attribute

    names

    Camel-case : The first character of a tag name is

    lowercase and the first letter of any subsequent

    words are in uppercase.

    Attribute values

    Pascal-case : The first character is uppercase and

    the first letter of any subsequent concatenatedwords is uppercase. Exceptions being true and

    false, which are in lowercase.

    Configuration files are stored in plain text, which enables web developersto edit them in any text-editor of their choice.

    The ASP.NET configuration files are written in XML, which enables thedeveloper to modify them using an XML parser too

    If the configuration settings are changed, they are automatically detectedby the system. The server need not be restarted.

    DirectorySubDirector

    y

    Each directory can actually override the configuration of the previous

    directory by creating its own configuration file.The clients cannot view the contents of the configuration files using a

    browser, thus, ensuring security.

    CONFIGURATION FILES

    Configuration Files

    Machine.Config Web.Config

    It setsproperties applicable

    fortheentireserver,and

    is an XML basedfile

    It setsproperties applicable

    fortheentireserver,and

    is an XML basedfile

    Containsproperty settings just

    fora single applicationor

    evenmay be a singledirectory

    ofan application.

    Containsproperty settings just

    fora single applicationor

    evenmay be a singledirectory

    ofan application.

    Server Configuration File

    TOPIC

    HOME

    26

  • 8/8/2019 Presentation on Asp.Net

    30/31

    HomeHomeWORKING WITH WEB OBJECTSWORKING WITH WEB OBJECTS

    CONFIGURATION FILES

    Web

    Pages

    Set the

    Property

    Values

    Application

    Configuration

    File

    Web.Config

    This web.configis an base file

    Web.Config File Structure

    Root

    Directory

    Of

    Application

    Web Config

    An applicationis configured

    using theweb.configfilewhich residesin theroot directory

    ofthe application.

    TOPIC

    HOME

    27

  • 8/8/2019 Presentation on Asp.Net

    31/31

    HomeHome

    ThankingYou . . .

    A.

    A WORD OF THANKS . . .A WORD OF THANKS . . .