|I l @ ve RuBoard|
Before we build our first ASP.NET page, let's go over some of the basic differences between ASP and ASP.NET, with regard to the file system and organization, and some architectural considerations.
The first thing to note is that the file extension for an ASP.NET page is different from that of a Classic ASP page. Instead of using .asp, you use .aspx as your file extension. Similarly, in an ASP application you used the global.asa file to manage some of the application events, and in an ASP.NET application you will use the global.asax file. In addition to the global.asax file, an ASP.NET application also has a web.config file, which is used to set many application-specific configuration settings. Unlike the global.asax, web.config files are inherited by applications in subfolders . In fact, all .NET applications on a given server inherit from a base config file, machine.config, located in the operating system directory.
Table 3.1. Important ASP.NET File Types
Maintaining State Between ASP and ASP.NET
One thing to be aware of as you migrate your files from ASP to ASP.NET is that session state is not shared across the two architectures. That is, while you certainly can migrate to ASP.NET one page at a time, .aspx page and .asp pages cannot share the same session state. If your application relies heavily on session variables , this is something to consider. There are several ways to deal with this problem.
Another thing you will quickly run into as you convert your .asp pages to .aspx pages is the language difference. VBScript is no longer used; instead VB.NET (VB7) (or another .NET language) is used for ASP.NET development. JScript, although still supported, has undergone a great deal of revision in order to be compliant with .NET. This book will focus primarily on VB.NET and C# for its examples. Listings 3.1, 3.2 and 3.3 show a very simple page that uses code to display Hello World to the browser. You can see that there are some important language differences between the current ASP languages and the new ASP.NET languages.
Listing 3.1 Source code for HelloVB.asp.
<%@ Language=VBScript %> <%Option Explicit%> <html> <head> </head> <body> <% Response.Write "Hello World" %> </body> </html>
Listing 3.2 Source code for HelloVB.aspx.
<%@ Page Language="VB" %> <html> <head> </head> <body> <% Response.Write("Hello World") %> </body> </html>
Listing 3.3 Source code for HelloCS.aspx.
<%@ Page Language="C#"%> <html> <head> </head> <body> <% Response.Write("Hello World"); %> </body> </html>
Figure 3.1 is an example of what the output of one of these files would be. Displayed is HelloVB.aspx, but each of the files would produce the exact same output.
Figure 3.1. HelloVB.aspx.
You can see these and every other example in this book by going to:
As you can see, there are some subtle differences in syntax between VBScript and VB.NET. We will see as we move on through the book that C# has its own unique syntax as well, which is very close to C/C++, JScript, or Java. However, because all languages in ASP.NET rely on the same .NET Framework of objects, the code for any given function often looks very similar regardless of the language in which it was written.
For a quick reference to the VB.NET language, refer to Appendix C.A similar reference to C# is found in Appendix D.For now, just remember one key difference between VB and VBScript, which is that methods now require parentheses, and will not compile without them. We'll see more differences as we continue, and answer some questions you may have about the new C# language.
|I l @ ve RuBoard|