Discovering Visual Basic .NET's Internet Technology: ASP .NET
ASP .NET is the technology built into .NET that you use to create Web pages and other Internet-based applications. ASP.NET is not merely the next version of ASP (Active Server pages). ASP was thrown out and ASP.NET was written from the ground up. It's a brand new, object-oriented language.
ASP.NET involves two primary technologies: WebForms, which are user-interface controls with code behind them that together make a Web page for visitors to view in their browsers; and Web Services, which are a class or classes that provide functionality but no user interface. Web Services cannot be viewed in a browser; they are only used programmatically in a way similar to how a VB Windows form might use functions stored in a traditional VB Module.
The purpose of ASP
The main idea of Active Server Pages is that people (or just one person) are surfing around the Internet (or a local intranet) and arrive at a page in your Web site. But instead of merely seeing static, canned content on that page (simple, pre-written HTML), you want to provide dynamic content. The best way to dynamically interact with a visitor is to generate the Web page on your server right then and there. Then you send the resulting fresh HTML to the visitor.
This is how you can make your Web site attractive, up-to-date, varying, and interesting to the visitor. Also note that a given Web page may be used by thousands of people simultaneously. This possibility requires some adjustments in how you program. For example, how can your program persist (remember) global variables?
Web pages are programmed in a language called HTML, which browsers such as Internet Explorer understand and respond to. Pure HTML merely describes how text and graphics should look — size, location, color, and so on. You can do no significant computing with HTML. You cannot even add 2 + 2. By itself, HTML is pretty useless.
HTML merely specifies that a headline is relatively large, that some body text on the Web page is colored blue, that one graphic is lower on the page than another graphic, and so on. HTML also includes a few simple objects such as tables and listboxes. However, even the tables and listboxes are static, essentially lifeless, display objects.
To expand the capabilities of HTML, the idea of an active server was developed. It permits you to compute on your server; then the results of that computation are composed into a page of HTML. The HTML page is then sent off to the visitor's computer for viewing in his or her browser. This capability brings your Web pages alive.
ASP, therefore, permits you to do many useful things on your server that you could never do with HTML. You can access a database, insert prewritten components, revise your Web pages (include news about your company, today's date, and so on) so that visitors don't get bored seeing the same content each time they visit, and many other valuable techniques. The visitor sees the most recent product announcements, late-breaking information, and anything else you want to provide. Your Web pages become interactive, responsive, and timely.
Firewalls and other necessary evils
Because ASP sends standard HTML to the visitor, ASP overcomes a browser-compatibility problem. It doesn't matter if people are using Netscape, Internet Explorer (IE), or some other browser — they can view your standard HTML pages. In addition, firewalls — designed to keep hackers, whackers, viruses, worms, and other invaders out of your computer — are designed to permit HTML to pass unchallenged. Innocent, merely descriptive, merely visual HTML can do no damage to your computer, any more than a picture of a gun can fire.
You can insert scripting into an HTML page and, therefore, let the visitor's computer do some limited computing. This is called client-side scripting. It works fine if you're sure that all your visitors have the necessary language components installed on their machines, that their security settings permit scripting (many block scripts), and that they are all using the same browser (and that browser supports scripting). So, if you're merely running a site that is intended for use in-house on an intranet, and everybody in your company uses IE, and you're sure they all have the right components on their hard drives, go ahead and try some client-side computing. Intranets often permit scripting. However, you have many reasons to prefer server-side computing that sends HTML results to clients.
Marching toward ASP.NET
Programmers wanted more than ASP offered, and now you can see file and Web page extensions named ASPX. That extension tells you that ASP.NET is being used. In fact, much ASP source code can run just fine without any serious modifications by using the ASP.NET engine. So, to force an ASP source code file to run under ASP.NET, just change its filename extension from .ASP to ASPX. In some cases, it can work without modification.
ASP.NET doesn't require that you jettison any existing ASP code you've written. In fact, ASP pages can run side by side, simultaneously with ASP.NET pages. You can keep your current ASP Web applications running on the same server as new ASP.NET Web applications you create.
The following list is a sampling of the strengths and features that you'll find when you begin using ASP.NET:
- ASP.NET code is easier to write, debug, and maintain than ASP, particularly for larger projects. ASP.NET provides you with a generous suite of debugging tools that were simply unavailable in ASP (including breakpoints, tracing, and extensive error messages).
- ASP.NET code can be written in the full Visual Basic.NET language, so you can leverage some of your existing programming knowledge, transferring your experience from the Windows OS platform to the browser intranet/Internet platform.
- Legacy ActiveX components that you've written can be used with .NET languages.
- Powerful IDE debugging tools are available.
- You get WYSIWYG design and editing.
- Wizards can step you through tedious or complex tasks.
- The object-oriented foundation of ASP.NET programming can make it easier to read, reuse, maintain, and share code among groups of programmers who must work together on a single project.
- ASP.NET VB.NET source code is written in a separate window and saved in a separate file from the HTML. (HTML is also used to contribute to an ASP.NET Web page.) This code-behind feature makes life easier because you don't have to try to read through mixed HTML/VB.NET source code.