; 2_dotnet_aspnet
Documents
Resources
Learning Center
Upload
Plans & pricing Sign in
Sign Out
Your Federal Quarterly Tax Payments are due April 15th Get Help Now >>

2_dotnet_aspnet

VIEWS: 9 PAGES: 31

  • pg 1
									.NET and ASP.NET

   The Microsoft .NET framework
   What is ASP.NET
   How ASP.NET operates
   Examples of ASP.NET code
What is .NET (By Microsoft)

   “Microsoft .NET is a set of Microsoft software
    technologies for connecting your world of information,
    people, systems and devices.”
   “The .NET Framework is a development and execution
    environment that allows different programming
    languages & libraries to work together seamlessly to
    create Windows-based applications that are easier to
    build, manage, deploy, and integrate with other
    networked systems.”
What Really is .NET
   .NET is a software platform, an environment for writing
    and running programs that can easily and securely
    interoperate.
    –   A Microsoft product: on the server side, you need to run a
        Windows system (ASP.NET not supported in Win95)
    –   Current version:1.1 (2.0 coming up in 2005)
   The core of .NET:
    –   Compiler: to compile high-level languages (e.g. VB.NET, C#,
        C++) into Intermediate Language (IL).
    –   Virtual Machine: Turn IL into machine code
    –   Class library: Functionality for Windows GUI development,
        database access, web development and XML, etc.
.Net Supports (By Microsoft)

   Standard networking protocols:
    –   TCP/IP, SOAP, XML, HTTP, etc
   Different programming languages
   Programming libraries
   Different platforms
What .NET Really Supports

   Different programming languages:
    –   C#, VB.Net, C++, Java
   Latest windows platform:
    –   Windows XP Pro (not Home), Window 2K, Server,
        CE
    –   Does not support: non-Windows, Windows 95,
        windows 98/ME (for development)
   Class libraries: strength
Developing .NET Applications

   Need to download and install the .Net Framework from
    Microsoft: the minimal environment to run and develop
    .Net applications (free)
   Development tools:
    –   .Net Framework SDK (command-line compilers, free)
    –   ASP.NET WebMatrix: free IDE tool with web server
    –   VisualStudio.NET 2003: expensive but free through MSDNAA
   WebMatrix and VS.NET are available in 7 and 24 DKH.
Components of .NET (By Microsoft)

   .NET utilizes XML for software integration that allows
    small, discrete, building-block applications to connect
    to each other - as well as other larger applications - via
    Internet (www.microsoft.com/net/basics/whatis.asp)
    The four main components of .NET are:
    –   XML Web Services
    –   Smart Clients
    –   Developer Tools
    –   Servers
What is XML?

   XML standards for eXtensible Markup Language
   XML is a method of storing data using mark-up tags
   Example:
    <person>
    <firstname> Mu </firstname>
    <lastname> Xia </lastname>
    </person>
   How does it compare with HTML?
Why All the Fuss About XML?

   XML’s advantage:
    –   Simple text format
    –   Flexible to define different data types
    –   Can be used to store any structured data: e.g. music notes,
        math equations, in text format.
   XML makes it easy to share information between
    programs, so programs can easily interoperate
    –   Before XML, interoperation (programs calling programs) was
        possible but very tedious
XML Makes Data Sharing Easy in
Business

   The travel industry:
    –   Passenger information
    –   Trip information
    –   Itineraries
   The mortgage industry:
    –   Borrower information
    –   Loan information
    –   Credit history
Discussion

   Think of an example where XML can be used
    help data sharing in the business process to
    increase efficiency or create new business
    opportunities
XML Web Services

   Programs calling other programs on the web using
    XML
   Before XML, all information (output of server-side
    programs) is available via HTML on the web
    –   For display in user browser only
    –   Not easy for program to use the information
   In web services, functions are exposed through the
    web services interface to the web
    –   So one program can call the web services easily
Web Services Example
   Amazon Light:
    –   http://www.kokogiak.com/amazon4/
    –   Gets all information about products from Amazon’s Web
        Services interface (free service by Amazon)
    –   Amazon gives out the service for free to increase its reach
   Google Web API (Application Programming Interface):
    –   Search Google automatically via a programming interface
    –   Has many uses. For example, can be used to:
            Issue regularly scheduled search requests to monitor the web for
             new information on a subject.
            Search via non-HTML interfaces, such as the command line,
             pagers, or visualization applications.
.NET Framework
Discussion



Give an example of potential use of web services
  on a web site you frequent
What is ASP.NET

   Stands for Active Server Pages.NET
   (A significant) upgrade from ASP
   ASP.NET is a programming framework that
    can be used on a .NET server to build dynamic
    web applications
    –   A programming framework (not a language)
    –   For dynamic web applications
    –   On a .NET server
ASP.NET in .NET




   ASP.NET
   MS Intermediate Language
   CLR (Common Language Runtime)
   .NET Class library
From ASP.NET to Machine Code
   First: WebPages are written in ASP.NET
   Second: ASP.NET code gets converted into the
    standard .NET language (MS Intermediate Language,
    MSIL)
    –   All types of acceptable programming languages are
        transformed into the common MSIL
    –   Humans are not able to easily read this code
   Third: Common Language Runtime (CLR) is used to
    execute the MSIL.
    –   Coordinates actions between Windows and IIS
    –   Is the heart of the .NET framework
   Fourth: CLR uses the Just-In-Time (JIT) compiler to
    completely transform the code into machine code
How ASP.NET Operates

   Regular HTML with special sections “marked”
    for special consideration
   Must have .aspx suffix to be interpreted
    correctly
   Three methods for inserting ASP.NET code
    –   Script tags
    –   Inline code blocks
    –   Server Controls
Script Tags

   Best way to delimit ASP.NET code from HTML
    –   <script language=“VB” runat=“server”>
        …VB.NET declarations go here…
        </script>
            Runat=“server” – this must be specified because the
             default is to run the script at the client
            All code in the <script> element must be written in the
             same language
Script Tag Example #1
<script language=“vb” runat=“server”>              Tells the server
Sub Page_Load()
   Response.Write (“First ASP.NET Line <br />”)
                                                   to do this first
   Response.Write (“Second ASP.NET Line <br />”)   when the page
   Response.Write (“Third ASP.NET Line <br />”)    loads
End Sub
</script>                                          Object
<html>
   <body>
          Line 1: First HTML Line <br />           Class
          Line 2: Second HTML Line <br />
          Line 3: Third HTML Line <br />
   </body>
</html>
HTML for Example #1 Output
First ASP.NET Line<br />Second ASP.NET Line<br />Third ASP.NET
    Line<br />
                                         HTML produced by Server
<html>                                   script
 <head>
   <title>Inserting ASP.NET code Example</title>
 </head>
 <body>
   Line1: First HTML Line<br />
   Line2: Second HTML Line<br />               normal HTML
   Line3: Third HTML Line<br />
 </body>
</html>
Example #1 Output
First ASP.NET Line               The script tags tell the server to
Second ASP.NET Line              execute their enclosed contents
                                 before the rest of the HTML
Third ASP.NET Line
Line 1: First HTML Line
Line 2: Second HTML Line         Produced by normal HTML
Line 3: Third HTML Line
http://www.cba.uiuc.edu/mxia/class/aspbook/ch02/message2.aspx
Script Tag Example #2
<html>
    <body>                                          Note: Any code placed
          Line 1: First HTML Line <br />            within <script> tags must
          Line 2: Second HTML Line <br />           always be placed in a
          Line 3: Third HTML Line <br />            subroutine, for example
          <script language=“vb” runat=“server”>     Page_Load
          Sub Page_Load()
             Response.Write (“First ASP.NET Line <br />”)
             Response.Write (“Second ASP.NET Line <br />”)
             Response.Write (“Third ASP.NET Line <br />”)
          End Sub
          </script>
    </body>
</html>
Example #2 Output
First ASP.NET Line
Second ASP.NET Line
Third ASP.NET Line
Line 1: First HTML Line
Line 2: Second HTML Line
Line 3: Third HTML Line
   Even though the HTML code was placed first, the
    ASP.NET code was still executed first
    –   Reason: the web server first scans the file for any <script
        runat=“server”> tags. If one is found, then it is executed first.
Inline Code Blocks
   Backward compatible with ASP
   Code can be interweaved into HTML using the <% %>
    delimiters.
   Makes code hard to read, hard to maintain and can
    slow down the compiler.
<html>
   <body>
     Line 1: First HTML Line<br />
     <% Response.Write (“First ASP.NET Line<br />”) %>
     Line 2: Second HTML Line <br />
     <% Response.Write (“Second ASP.NET Line<br />”) %>
   </body>
</html>
HTML for Inline Code Example
<html>
 <body>
   Line1: First HTML Line<br />
   First ASP.NET Line<br />
   Line2: Second HTML Line<br />
   Second ASP.NET Line<br />
 </body>
</html>
http://www.cba.uiuc.edu/mxia/class/aspbook/ch02/messa
   ge4.aspx
Display of Incline Code Blocks
Example
Line 1: First HTML Line
First ASP.NET Line
Line 2: Second HTML Line
Second ASP.NET Line


   Notice how the ASP.NET and HTML are
    interweaved. Compare this to the script tags
    example.
Server Controls
   Great Alternative to using inline code blocks
   Makes code easier to read and more portable
   Recommendation: place ASP.NET code in a
    declarative code block near the top of the file:
       <script language=“vb” runat=“server”>
         …ASP.NET code here…
       </script>

       <html>
         …HTML code here…
       </html>
Server Controls Example
<script language=“vb” runat=“server”>
Sub Page_Load()
    Message.Text=“The ASP.NET Line”
                                                       Server Control: tells
End Sub                                                server when and
</script>                                              what type element to
<html>                                                 display based on
<body>                                                 what is in the script
    First HTML Line <br />
                                                       tags
    <asp:label id=Message runat=“server”/> <br />
    Second HTML Line <br />
</body>
</html>

  Disclaimer: Don’t worry if you don’t understand this yet, this is just a preview.
Exercise

Based on the examples, write an ASP.NET
  program that will generates a page with “Hello,
  world” displayed. Use the following two
  approaches and discuss the differences:
 Server controls
 Inline blocks

								
To top