Getting Started
  Introduction
  What is ASP.NET?
  Language Support

ASP.NET Web Forms
  Introducing Web Forms
  Working with Server Controls
  Applying Styles to Controls
  Server Control Form Validation
  Web Forms User Controls
  Data Binding Server Controls
  Server-Side Data Access
  Data Access and Customization
  Working with Business Objects
  Authoring Custom Controls
  Web Forms Controls Reference
  Web Forms Syntax Reference

ASP.NET Web Services
  Introducing Web Services
  Writing a Simple Web Service
  Web Service Type Marshalling
  Using Data in Web Services
  Using Objects and Intrinsics
  The WebService Behavior
  HTML Pattern Matching

ASP.NET Web Applications
  Application Overview
  Using the Global.asax File
  Managing Application State
  HttpHandlers and Factories

Cache Services
  Caching Overview
  Page Output Caching
  Page Fragment Caching
  Page Data Caching

Configuration
  Configuration Overview
  Configuration File Format
  Retrieving Configuration

Deployment
  Deploying Applications
  Using the Process Model
  Handling Errors

Security
  Security Overview
  Authentication & Authorization
  Windows-based Authentication
  Forms-based Authentication
  Authorizing Users and Roles
  User Account Impersonation
  Security and WebServices

Localization
  Internationalization Overview
  Setting Culture and Encoding
  Localizing ASP.NET Applications
  Working with Resource Files

Tracing
  Tracing Overview
  Trace Logging to Page Output
  Application-level Trace Logging

Debugging
  The SDK Debugger

Performance
  Performance Overview
  Performance Tuning Tips
  Measuring Performance

ASP to ASP.NET Migration
  Migration Overview
  Syntax and Semantics
  Language Compatibility
  COM Interoperability
  Transactions

Sample Applications
  A Personalized Portal
  An E-Commerce Storefront
  A Class Browser Application
  IBuySpy.com

  Get URL for this page

Syntax and Semantics

ASP.NET is fully API-compatible with traditional ASP, with the following three exceptions:

  • Request(): ASP returns an array of strings; ASP.NET returns a string.
  • Request.QueryString(): ASP returns an array of strings; ASP.NET returns a string.
  • Request.Form(): ASP returns an array of strings; ASP.NET returns a string.

In ASP, the Request, Request.QueryString, and Request.Form collections return string arrays from lookups. For example, in traditional ASP the query string values from a request to http://localhost/test/Test.asp?values=45&values=600 would be accessed as follows:

<%
    ' Below line outputs: "45, 600"
    Response.Write Request.QueryString("values")

    ' Below line outputs: "45"
    Response.Write Request.QueryString("values")(1)
%>

In ASP.NET, these collections require an explicit method to get array access. These arrays are also now 0-index based. For example, in ASP.NET the query string values from a request to http://localhost/test/Test.aspx?values=45&values=600 would be accessed as follows:


<%
    ' Below line outputs: "45, 600"
    Response.Write(Request.QueryString("values"))

    ' Below line outputs: "45"
    Response.Write(Request.QueryString.GetValues("values")(0))
%>
VB

These arrays are most commonly used when form values are posted from multiselect list boxes (<select multiple>) or when multiple check boxes have the same name.

Semantic Differences Between ASP.NET and ASP
ASP.NET pages also have several semantic changes from existing ASP pages. The following issues are the ones most likely to affect you:

  • ASP.NET pages only support a single language.

    ASP allowed multiple languages to be used on a single page, which was useful for script library scenarios. Because of ASP.NET's compiled nature, it supports only a single language on a page. However, it is still possible to have multiple pages, each with a separate language, within a single application. User Controls might also have a different language from the page that contains them. This enables you to integrate functionality written in different languages in a single page. This is an adequate substitute for the multiple-language Include files that are prevalent in traditional ASP applications.

  • ASP.NET page functions must be declared in <script runat=server> blocks.

    In ASP, page functions could be declared within <% %> blocks:

    <%
        Sub DoSomething()
            Response.Write "Hello World!"
        End Sub
    
        DoSomething
    %>
    

    In ASP.NET, page functions must be declared in <script runat=server> blocks:

    
    <script language="VB" runat=server>
    
        Sub DoSomething()
            Response.Write ("Hello World!")
        End Sub
    
    </script>
    
    <%
        DoSomething()
    %>
    
    VB

  • ASP.NET does not support page-render functions.

    In ASP, page-render functions could be declared with <% %> blocks:

    <% Sub RenderSomething() %>
           <font color="red"> Here is the time: <%=Now %> </font>
    <% End Sub %>
    
    <%
       RenderSomething
       RenderSomething
    %>
    

    In ASP.NET, this must be rewritten:

    
    <script language="VB" runat=server>
    
         Sub RenderSomething()
            Response.Write("<font color=red> ")
            Response.Write("Here is the time: " & Now)
         End Sub
    
    </script>
    
    <%
       RenderSomething()
       RenderSomething()
    %>
    
    VB

Section Summary

  1. With three exceptions, ASP.NET is 100% API-compatible with traditional ASP. The API changes are that, now, Request(), Request.QueryString(), and Request.Form() all return individual strings, rather than string arrays.
  2. ASP.NET pages support only a single language.
  3. ASP.NET page functions must be declared in <script runat=server> blocks.
  4. Page-render functions are not supported.


Copyright 2001 Microsoft Corporation. All rights reserved.