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

Language Compatibility

The differences between the VBScript used in ASP and the Visual Basic .NET language used in ASP.NET are by far the most extensive of all the potential migration issues. Not only has ASP.NET departed from the VBScript language to "true" Visual Basic, but the Visual Basic language itself has undergone significant changes in this release. The changes are designed to:

  • Make the language more consistent by bringing together features of the language with similar purposes.
  • Simplify the language by redesigning the features that made Visual Basic less than "basic."
  • Improve readability and maintainability by redesigning features that hid too many important details from the programmer.
  • Improve robustness by enforcing better practices, such as type-safe programming.

This section highlights some common issues you are likely to encounter when you begin to use the new Visual Basic language.

  • No more Set and Let. Instead, use simple variable assignment.
    <%
        ' Old ASP syntax.
        Dim MyConn
        Set MyConn = Server.CreateObject("ADODB.Connection")
    
        ' New ASP.NET syntax.
        Dim MyConn
        MyConn = Server.CreateObject("ADODB.Connection")
    %>
    
  • No more non-indexed default properties. Non-indexed default properties enable an expression that normally refers to an object to refer to a default property of the object instead. The unfortunate consequence of support for default properties is that it makes programs more difficult to read, since the meaning of an expression depends on its context. In Visual Basic .NET, non-indexed properties must always be specified explicitly within code.
    <%
    ' Old ASP syntax (retrieving recordset column value).
    Set MyConn = Server.CreateObject("ADODB.Connection")
    MyConn.Open("TestDB")
    Set RS = MyConn.Execute("Select * from Products")
    Response.Write RS("Name")
    
    ' New ASP.NET syntax (retrieving recordset column value).
    MyConn = Server.CreateObject("ADODB.Connection")
    MyConn.Open("TestDB")
    RS = MyConn.Execute("Select * from Products")
    Response.Write RS("Name").Value
    %>
    
    Indexed default properties are still supported:

    <%
    Dim RS As RecordSet
    
    ' This is allowed (indexed).
    RS.Fields(1).Value = RS.Fields(2).Value
    
    ' But these are not allowed (non-indexed).
    RS(1) = RS(2)
    RS(1).Value = RS(2).Value
    %>
    
  • Parentheses are now required for calling subroutines. Visual Basic now supports exactly the same syntax for calling subroutines and functions.
    ' Note parentheses with Response.Write.
    Sub DoSomething()
         Response.Write("Hello World!")
    End Sub
    
    ' Note parenthesws with DoSomething.
    DoSomething()
    
  • The new default is by-value arguments. In Visual Basic 6, if a user does not explicitly specify ByVal or ByRef on a parameter declaration, the calling convention defaults to ByRef. In the new Visual Basic .NET, the default is ByVal. This applies both to regular parameters for which the default can be overridden by explicitly specifying ByRef and to parameters passed to a ParamArray parameter where the default can not be overridden. This has been changed because it is much more common for a parameter to be used solely for passing a value into a procedure than for altering a passed-in variable. Changing the default to ByVal increases performance and decreases the likleihood of accidental side-effects.

    You can still use by-reference arguments by explicitly using the ByRef modifier:

    <script language="VB" runat=server>
    
       Sub DoSomething(ByRef value)
          value = 4343
       End Sub
    
    </script>
    
    <%
       Dim number = 55
       DoSomething (number)
       Response.Write ("Number: " & number)
    %>
    
Note: There are many additional differences between Visual Basic 6 and Visual Basic .NET. Consult the language documentation for more information.

Section Summary

  1. The differences between the VBScript used in ASP and the Visual Basic .NET language used in ASP.NET are by far the most extensive of all the potential migration issues. The changes have been made to simplify the language and improve consistency, readability, maintainability, and robustness.
  2. Set and Let assignments are no longer supported in Visual Basic .NET. Use standard variable assignment instead.
  3. Non-indexed default properties are not supported in Visual Basic .NET. Indexed default properties are still supported.
  4. Parentheses are required for calling subroutines in Visual Basic .NET.
  5. The new default is by-value arguments. You can still use by-reference arguments by explicitly using the ByRef modifier.


Copyright 2001 Microsoft Corporation. All rights reserved.

GoToMyPC | ASP.NET Knowledge Base