Introducing ASP.NET - Active Server Pages .NET (Page 3 of 5 ) The easiest way to introduce ASP.NET is to highlight the most fundamental difference from ASP. Even if you have not used ASP before, you will be able to follow the general idea—we simply contrast the concept, not the technicalities. The Request/Response Model Recall that in web pages, you send an HTTP request (for example, a URL and the data in a form) to the server and it sends back a response (a web page). Your browser then typically displays that response. When you click various web page elements, such as buttons or links, one of two things can happen. If the web page has client-side script code (downloaded with the web page, typically in JScript or JavaScript), an event handler might handle the event without even talking to the server. Or, depending on the HTML code for the web page element (such as a Submit button), your browser might send an HTTP request to the server. The programming model for classic ASP is based on the HTTP request/response model. This programming model can be fairly difficult to use because you have to save data across HTTP requests and responses so that you can reconstruct the state of a page at every request. This contrasts with the simpler event-driven forms and controls model that most Windows applications use. For example, if you had a wizard-like series of pages in your web application, you would have to submit all the accumulated data to each page as hidden inputs, whereas a desktop application can simply access the data anytime. The ASP.NET Forms-Based Model The programming model in ASP.NET adds forms and controls. The programming model embodied by ASP.NET Web Forms is fairly similar to that of a Windows application, although the mechanisms underneath the programming models are very different. Conceptually, a pure Web Forms application consists of a set of forms that contain controls and HTML. The controls have properties and methods, and they can generate events. These events are usually handled on the server, although it’s possible to handle certain events on the client. This is a much simpler model than the ASP model because you don’t have to think about how the browser will reconstruct the state of the page—ASP.NET takes care of that. You only have to create the logic of interaction between the controls of a web page and the logic between web pages. The abilities of ASP.NET are also augmented by access to a whole new range of components, making it more like a true desktop application. The three-tier schematic then looks as shown in Figure 3-3.  Figure 3-3. The ASP.NET position within the Windows environment
More About ASP.NET There are many more aspects of ASP.NET that are of interest to web developers. - Not just a script: ASP.NET is not just the ASP version that can run within .NET. As mentioned before, it can be written using up to 20 languages, in addition to the 4 built-in ones: VB .NET, C#, C++, and JScript .NET. A list of ongoing projects on .NET ports of various languages can be found at http://www.cetus-links.org/oo_dotnet.html#oo_dotnet_netlang. ASP.NET also allows you to take full advantage of the features of the CLR, such as type safety, inheritance, language interoperability, and versioning.
- More built-in controls: Classic ASP was easy to use and made the creation of dynamic web content easy, but as the complexity of the dynamic content increased, the code necessary to enable complex pages became unmanageable. ASP.NET simplifies the creation of complex pages by providing prebuilt server-side controls and object types that web developers can use much like the drag-and-drop controls that developers use in Windows desktop applications.
Real-time configuration: There’s no need to restart the web server anymore. ASP.NET is configured via easy-to-read XML files that are editable with any text editor and that take effect the moment they’re saved. The same is true for components that are used in your pages—as soon as the DLL file is copied, the .NET Framework takes care of installation and registration so that it’s immediately available for use inside ASP.NET pages. Advanced browser handling: Because ASP.NET writes the HTML for ASP.NET controls, you don’t have to worry about writing different HTML for different browsers. Instead, ASP.NET detects what browser is being used and generates the appropriate HTML. All you do is use the high-level controls and let ASP.NET deal with the details. (This does not, however, get you out of testing your application against all the browsers you intend to support.) Easy programming model: You don’t have to worry about re-creating the state of each control in your page for each request. You can concentrate on writing code for how the controls can interact and ASP.NET handles the presentation to web clients. Rich class framework: Application features that used to be hard to implement or required a third-party component can now be added in just a few lines of code using the .NET Framework. The .NET Framework offers over 4,500 classes that encapsulate rich functionality like XML, data access, file upload, regular expressions, image generation, performance monitoring and logging, transactions, message queuing, SMTP mail, and so on. Compiled execution: ASP.NET dynamically compiles your pages and stores the compiled results so they can be reused for subsequent requests. ASP.NET will also automatically detect any changes you make and recompile them in real time. Dynamic compilation ensures that your application is always up to date, and compiled execution makes it fast. Most applications migrated from classic ASP are three to five times faster in pages served. Rich output caching: ASP.NET output caching can dramatically improve the performance and scalability of your application. When output caching is enabled on a page, ASP.NET executes the page just once and then saves the result in memory, in addition to sending it to the user. When another user requests the same page, ASP.NET serves the cached result from memory without reexecuting the page. Output caching is configurable and can be used to cache individual regions or an entire page. - Web farm session state: ASP.NET session state lets you share session data and user-specific state values across all machines in a cluster of web servers, known as a web farm. Users who were once directed to the server holding their session’s state now can hit different servers in the web farm over multiple requests and still have full access to their session.
- Memory leak, deadlock, and crash protection: ASP.NET automatically detects and recovers from errors like deadlocks and memory leaks to ensure that your application is always available to your users. ASP.NET automatically starts another copy of the ASP.NET worker process if the old one is running an application with memory leak problems, and it directs all new requests to the new process. Once the old process has finished processing its pending requests, it is gracefully disposed of and the leaked memory is released.
- Easy deployment: ASP.NET dramatically simplifies installation of your application. With ASP.NET, you can deploy an entire application as easily as an HTML page: Just copy it to the server. No need to run regsvr32 to register any components, and configuration settings are stored in an XML file within the application.
- Easy migration path: You don’t have to migrate your existing applications to start using ASP.NET. ASP.NET runs on IIS side-by-side with classic ASP on Windows 2000 and Windows XP platforms. Your existing ASP applications continue to be processed by asp.dll, whereas new ASP.NET pages are processed by the new ASP.NET engine. We will show you the details of this in the Appendix.
- XML web services: XML web services allow applications to communicate and share data over the Internet, regardless of operating system or programming language. ASP.NET makes exposing and calling XML web services simple. Any class can be converted into an XML web service with just a few lines of code, and any class can be called by any Simple Object Access Protocol (SOAP) client. Likewise, ASP.NET makes it incredibly easy to call XML web services from your application. No knowledge of networking, XML, or SOAP is required.
- Mobile web device support: ASP.NET Mobile Controls is a new group of server controls that work at a more abstract level than regular ASP.NET controls. Mobile Controls let you easily target cell phones and PDAs (including over 80 mobile web devices) using ASP.NET. The list of supported devices is also easily updatable via configuration files, and like everything .NET, it is completely extensible to cover any future type of device. You write your application just once and the mobile controls automatically generate WAP/WML, HTML, CHTML, or your custom XML language, as required by the requesting device.
Now that you know where ASP.NET fits into the web developer’s radar screen, let’s get busy with the details. Next we discuss how an ASP.NET web site is created in Dreamweaver and IIS. Next: Creating an ASP.NET Web Site >>
More ASP.NET Articles More By Apress Publishing | This article is excerpted from chapter three of the book ASP.NET Web Development with Macromedia Dreamweaver MX, written by Costas Hadjisotiriou et al. (Apress, 2004; ISBN: 1590593480). Check it out at your favorite bookstore. Buy this book now.
|
| |