Benefits of ASP.NET over ASP

I l @ ve RuBoard

ASP.NET and the .NET Framework feature many advantages over classic ASP. ASP.NET outperforms ASP, and is more robust, secure, and scalable. It has better tools, allowing programmers to be more productive, and it will support many different languages, allowing developers to use whichever one they prefer. ASP.NET will also be easier to manage and deploy. Let's expand on our list of advantages of ASP.NET over ASP that were mentioned at the start of this chapter.

ASP.NET Is Compiled, not Interpreted

Compiled programs run faster than interpreted ones. Thus, ASP.NET, which is compiled, runs faster than classic ASP, which is interpreted. Each page is compiled the first time it is requested , and then the compiled code of the page is kept until that page is changed or the application is restarted. Optionally, files can be precompiled at deployment time, to reduce latency when pages are first accessed.

Separation of Code from Content

ASP.NET will allow true separation of code from presentation, which will allow graphic designers and programmers to work together with less frustration and time spent merging pages' looks with their functionality. This is done through the use of "code behind" pages, which are referenced using a page directive in the header of the page with the presentation code.

No More "DLL Hell"

Users and developers of COM components have come to refer to the problems with COM deployment as "DLL Hell." This means that installing or moving COM components often breaks dependent applications without warning. Otherwise stable applications are frequently broken when a new application updates an existing component. "DLL Hell" exists because the COM protocol requires that components do not change the interfaces they expose, and so any time a component's interface changes, it gets a new identifier that basically makes it a new version of the component. Programs that relied on one version of a component are frequently broken when they try to communicate with a newer version of that component. If you have ever installed a new program on your computer only to find that some of your other programs no longer work afterward, you have experienced "DLL Hell."

With ASP.NET, components don't have to be shared across the server, but can be placed with individual applications. Also, components are kept with the application, and the entire application can be moved using simple file copying. No registry changes or dealing with MTS/COM+ is necessary! This makes it very easy to maintain an ASP.NET application remotely, such as through a Web hosting provider. Of course, components can still be shared, but that decision is now left to the developer or administrator.

Side-by-Side Installation

If you're not sure you're ready to migrate your production applications to ASP.NET yet, don't worry. The new services and features can be installed and running in parallel with your existing classic ASP applications (on IIS 4 or 5). In fact, they can share the same folder structure ”all that you need do to migrate each file (after you've made it utilize the new features of ASP.NET) is change the file extension from .asp to .aspx (and of course update your links to this file accordingly ). You will literally be able to migrate your applications a page at a time.

Real Debugging

ASP.NET features easier debugging than did Classic ASP (which isn't saying much). One simple addition is a trace command that is only compiled into the running code when a compile flag is set. No need to build your own debugging code using if-then and Response.Write . Also, with Visual Studio .NET, you can step through your ASP.NET code, your include files and Web controls, and your .NET components, even if each of these uses a different programming language, without being on the server. It is real debugging, just as with any other Visual tool!

Real Programming Languages

Although ASP supports several scripting languages, ASP.NET (and in fact the .NET Framework) will support any language that can be compiled to its intermediate language (IL) format, which at the time of printing includes over 16 different languages, including Ada, APL, COBOL, C#, Eiffel, Haskell, Jscript, ML, Oberon, OZ, Pascal, Perl, Python, Scheme, Smalltalk, VB, and others. Similar to Java (don't tell anyone ), ASP.NET languages are compiled to a standard format (the Intermediate Language, or IL) that the .NET architecture then compiles and executes with the Common Language Runtime (CLR). Note that there are quite a few differences between the implementation of .NET and Java, but they are beyond the scope of this book to cover. Microsoft .NET's language independence means that developers can use whatever programming language they feel most comfortable with and won't need to learn a new language to learn ASP.NET.

Real Error Handling

ASP.NET features better error handling, including the ability to send all programming errors to a single error handler page, transferring all of the page's attributes (like Request and other variables ) as well. Having a central location to manage errors is a vast improvement over having to check for errors every few lines of VBScript and write a custom error handler for each case.

Further, Visual Basic.NET now supports the Try...Catch structure familiar to Java and JavaScript programmers. Although On Error Resume Next is still supported, it is not recommended and should be replaced with Try...Catch blocks, which offer greater flexibility and better cross language compatibility.

Directory-Based Deployment

Migrating an ASP application from one server to another is a daunting task. FrontPage extensions, COM components, and Web settings are all separate from the actual files in the directory to be moved. With ASP.NET, you can deploy your application, complete with server settings and components, using XCOPY or FTP. This makes backing up a site much easier, and eliminates a lot of the hassle involved with remote Web hosting.

Once, in the days of MS-DOS, programs were as easy to install, move, and uninstall as directories were to copy. Moving the files moved the program. With the advent of Windows and the notorious system registry, this simplicity was lost. Now, with .NET, we can once again install entire applications using nothing more than a file manager or FTP client.

File-Based Application Configuration

Administering the application can be done entirely via XML configuration files ”no need for direct access to the server! Again, this makes remote maintenance much easier than with classic ASP. And because the configuration files use a standard XML format, you can expand them to include your own application-specific settings as well, and third-party administration tools can also be written to manage ASP.NET applications by using these files. The current beta of Visual Studio .NET does not offer a graphical means of maintaining these settings, but one is likely to be released in a later version of VS.NET.

Event-Based Programming Model

ASP pages are simple scripts that begin execution at the top of the file and continue line by line down the page until the script has completed. By contrast, ASP.NET pages feature an event-based programming model, which should be familiar to Visual Basic programmers. Page execution can now be viewed as a series of events and event handlers, such as a page loading or a button being clicked. This helps to eliminate much of the "spaghetti code" associated with ASP pages, making code easier to maintain and modify. This programming model also makes it much easier for powerful tools to be written to aid developers.

For example, to add some functionality to a button on a web page using Visual Studio .NET, the process mirrors that of VB6. First, you drag a button onto your page in Design View. Next, you double-click on the button, bringing up its "OnClick" handler. Finally, you add the code you want to execute to this method. Very straightforward, and minimal learning curve for anyone familiar with VB's environment.

Improved, Extensible Object Model

ASP.NET has an improved object model that will allow for improved development tools. Visual Basic Web Forms will provide to ASP.NET developers the drag-and-drop form-based interface familiar to users of Visual Basic. This makes building event-driven pages much simpler.

What's more, the .NET Framework includes an extensive list of classes available to the ASP.NET developer (in any .NET language). These classes cover a wide range of functions not included in any of the ASP 3.0 objects, such as easy browser file uploads, custom image manipulation, and advanced encryption functions. Although this functionality was only available through additional COM components in ASP 3.0, it is all available "out of the box" to the ASP.NET developer.

More Integrated Functions

Built-in form/state management means that you no longer need to explicitly access form variables using the Request object! All of this drudgery is now handled behind the scenes by ASP.NET. Simply adding runat ="server" to the form and each form element is the only coding needed.

Form validation functions, which can be done either server-side only, or both client-side and server-side, are built into ASP.NET. ASP.NET ships with many of the commonly required validation functions, and of course allows developers to build their own custom validation controls as well. Support for regular expressions means that very powerful validation functions can be written relatively easily. We will cover validation controls in Chapter 7.

Web Services

ASP.NET includes support for Web services, which allow applications to work together across the Internet by either exposing or consuming (or both) methods and data from other sites. Web services use the standard Simple Object Access Protocol (SOAP) to call methods across the Internet. This technology will allow Application Service Providers to easily expose their services, and will enable developers to easily integrate these services into their applications. Further, because the SOAP standard protocol is used, different applications running on different operating systems in different countries could easily communicate with one another through Web services. We will look more closely at how ASP.NET uses Web services in Chapter 11, "ASP.NET and Web Services."

Performance Improvements

ASP.NET's performance is greatly improved over classic ASP. One major advantage ASP.NET has over Classic ASP is that it is compiled, not interpreted. ASP.NET supports page-level caching, which can be configured on a page-by-page basis. This is one of the biggest scalability features to come out of ASP.NET. In classic ASP, the only way to achieve this was with complicated session and application variable code. In ASP.NET, it's a line of code to tell a page how long its output should be cached before executing again. Consider a catalog page that lists available inventory to order, being hit by fifty users per minute. In classic ASP that would be fifty database hits per minute (at least). With ASP.NET and one line of code, that page could be cached for five minutes (or as little or as long as desired), dropping database load to one hit per five minutes for this page, and greatly improving performance for the other 249 requests made in that time span. Page fragments and objects can also be cached, and caching is just one of several ways in which ASP.NET has enhanced application performance. All told, you can expect ASP.NET's performance to be at least two to three times that of Classic ASP's, with potential for more with the use of caching.

Better Tools

Lastly, ASP.NET features improved developer tools. Visual InterDev is no more. In its place is Visual Studio .NET, now an integrated application that features Web forms, which are built by dragging controls onto the form much like in Visual Basic. Visual Studio .NET also includes support for developing VB.NET, C++, C#, and so forth. There are no longer separate tools for each Microsoft-supported language; VS.NET does it all. It features so many improvements and wizards that we will give an overview of it in Appendix E.

I l @ ve RuBoard

Asp. Net. By Example
ASP.NET by Example
ISBN: 0789725622
EAN: 2147483647
Year: 2001
Pages: 154

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: