".NET" Programming Language - Features

Started by sivaji, Jan 10, 2008, 09:14 PM

Previous topic - Next topic

sivaji

Features

  1. ASP.NET Syntax and Supported Languages
  2. Samples
  3. Execution Process
  4. Assemblies
  5. State Management, Security, and Event Handling

Business Logic and Layout

   *  No more blending of HTML and scripting code
          *  Easy maintainability of your application
   *  Completely separate layout and processing logic
           *   No implementation code within HTML files
           *   Files for designers and files for programmers
           *   You can still mix HTML and scripting code if you wish

Supported Languages

   *  Visual Basic
           *  VBScript is unmanaged !
   *  JScript
   *  C#
           *   New component-based language
   *  C++
           *   Managed Extensions for C++
   *  Others: Cobol, Smalltalk, ...
           *   Common Language Specification (CLS)

C# Overview

   *  New component-oriented language from Microsoft
           *  Evolution of C and C++
           *   Introduces improvement in areas such as
                     *  Type safety, versioning, events and garbage collection
           *   Provides access to APIs like .NET, COM, or Automation
   *  "Hello World" sample

QuickStart

   *  Different files with different file name extensions
            *   Standard ASP.NET files: .aspx or .ascx
            *   Web Services: .asmx
            *   Code (behind) files: .aspx.cs, .asmx.vb, ...
            *   Configuration: Web.Config
            *   Web applications: Global.asax and Global.asax.vb
   *  All of them are text files
   *  The easiest way to start
             *   Change the .asp extension to .aspx

Page Syntax

   *  Directives
            <%@ Page language="VB" [...] %>
   *  Code Declaration Blocks
            <script runat="server" [...]>
                   [ lines of code ]
            </script>
   *  Code Render Blocks
             <%
                   [ inline code or expression ]
             %>
   *  HTML Control Syntax
              <HTMLelement runat="server" [attribute(s)]>
              </HTMLelement>
   *  Custom Control Syntax
         *   Custom server controls
                        <ASP:TextBox id="MyTb1" runat="server">
          *   Server control property
                        <ASP:TextBox maxlength="80" runat="server">
          *   Subproperty
                        <ASP:Label font-size="14" runat="server">
          *   Server control event binding
                        <ASP:Button OnClick="MyClick" runat="server">
   *   Data Binding Expression
              <asp:label
                   text='<%# databinding expression %>'
                   runat="server" />
   *  Server-side Object Tags
              <object id="id" runat="server"
                    identifier="idName" />
   *  Server-side Include Directives
              <!-- #include pathtype = filename -->
   *  Server-side Comments
             <%-- comment block --%>

ASP.NET Sample

<html>

<script language="VB" runat=server>
  Sub SubmitBtn_Click(Sender As Object, E As EventArgs)
    Message.Text = "Hi " & Name.Text
  End Sub
</script>

<body>
  <form action="thisfile.aspx" method=post runat=server>
    <h3> Name: </h3>
    <asp:textbox id="Name" runat=server/>
    <asp:button type=submit text="LookUp"
                OnClick="SubmitBtn_Click" runat=server/>
    <p>
    <asp:label id="Message" runat=server/>
    </p>
  </form>
</body>

</html>

.aspx Execution Cycle Execution process

   *  Compilation, when page is requested the first time
   *  Microsoft intermediate language (MSIL)
             *   Assembly languageā€“like style
             *   CPU independent
             *   Provides a hardware abstraction layer
             *   MSIL is executed by the common language runtime
   *  Common language runtime
             *   Just-in-time (JIT) compiler
             *   Managed code

Assemblies

    *  Result of compiling is still a .dll or .exe file
           *   Multiple- or single-file assembly

Metadata

   *  An assembly's manifest
           *  A manifest contains
                    *  List of all assembly files
                    *  Information about versioning, shared name
                    *  and more ...
           *   The information is used to
                    *  Locate and load class types
                    *  Lay out object instances in memory
                    *  Resolve method invocations and field references
                    *  Translate MSIL to native code
                    *  Enforce security

State Management

   *  Application State
           *   What is an "application"?
                       *  Files, pages, modules, and executable code
                       *  One virtual directory and its subdirectories
           *   Application state variables
                       *  Global information
           *   Implementation rules
                       *  Use of system resources
                       *  "Lock" and "unlock" your global information
                       *  Beware of global variables in multithreaded environments
                       *  Loss of state when host is "destroyed"
                       *  No state sharing across Web farms
   *  Session State
            *   What is a session?
                       *  Restricted to a logical application
                       *  Context in which a user communicates with a server
            *   Functionality
                       *  Request identification and classification
                       *  Store data across multiple requests
                       *  Session events
                       *  Release of session data
             *   .NET State Server Process

Security
   
   *  Reasons for Security
           *   Prevent access to areas of your Web server
           *   Record and store secure relevant user data
   *  Security Configuration in Web.Config
           *   <authorization>, <authentication>, <trust>, ...
   *  Authentication, Authorization, Impersonation
   *  Code Access Security
           *   Are you the code you told me you are?
           *   Protect your server from bad code
   *  Authentication
           *   Validates user credentials
           *   Awards an authenticated identity
           *   Types of authentication
                     *  Windows, integrating with IIS 5.0
                     *  Passport, centralized services provided by Microsoft
                     *  Forms, request attachment
   *  Authorization
           *   Determine whether request is permitted
           *   File and URL authorization
   *  Impersonation
           *   IIS authenticates the "user"
           *   A token is passed to the ASP.NET application
           *   ASP.NET impersonates the given token
           *   Access is permitted according to NTFS settings
   *  Code Access Security
           *   .NET Framework feature
           *   Verify the code's identity and where it comes from
           *   Specify operations the code is allowed to perform

Event Model

   *  Application-level Event Handling
           *   Web Forms
   *  Delegate Model
           *   Connect event sender and event receiver
           *   Single and multicast delegates
   *  Event Delegates Are Multicast
   *  Event Wiring
           *   Register event handler with event sender
   *  Events raised on client, but handled on server

Event Samples

   *  Event samples
            *   System.Web.UI.WebControls
                 Class Button, public instance event Click
            *   System.Web.UI
                 Class Page, public instance event Load
   *  Events in C#
             ASP.NET
             C#
Am now @ Chennai