Search This Blog

Oct 28, 2012

Asp.Net Tutorial (PART-2)

Separation of Code from Content

As I mentioned previously, a major drawback of ASP in certain instances is that there is no way to separate code from page content. In ASP.NET, due to the introduction of server controls and the event-driven model, the trend leans toward placing all the code in event handlers in one place in the file (normally at the top). If this isn't sufficient, it's also possible to totally separate code from content by placing all the code in a separate file (VS .NET does this by default).

Session State Management

ASP provided a special collection object where the programmer could store variables pertaining to a particular visitor's session. This was a commonly used feature, but it had three major shortcomings. First, it wasn't Web farm-friendly. Session state variables were stored in the IIS process space, and as such, they were tied to a specific machine. Thus, if a visitor to a site had a particular piece of information stored in a session variable on a particular request, and he or she was then sent to another server on the next request, the ASP code would not be able to retrieve the previously stored
value. Second, a disadvantage of storing session state in the IIS process space is that should the IIS service have to be restarted, the session information is lost. The third problem was slightly more subtle, but important nonetheless: ASP kept track of visitor IDs by using cookies, which aren't supported by all browsers, or are not guaranteed to be enabled in all user browsers.

ASP.NET offers solutions for all the problems presented. First, it's now possible to store session state in a SQL Server database, which is naturally accessible to all the servers in a Web farm. Second, it's possible to store session state out of process, which alleviates the problem of IIS service restarts. Third, ASP.NET now allows for cookie-less session state management.

User Input Validation

A major aspect of plumbing that ASP requires is that of input validation checking that information that users have entered is in the correct form. ASP.NET provides a set of server controls that make this task almost trivial. These controls are intelligent and produce client-side validation code for supporting browsers and server-side code for the rest.

Web Services

Web Services are a large part of ASP.NET and .NET as a whole. Web Services are classes, or objects, that expose certain methods and make them accessible over the Internet. Web Services are based entirely upon open standards such as Simple Object Access Protocol (SOAP), XML, and HTTP, thus allowing interoperability with "Web services" on other platforms, such as UNIX, as well as those built using the Visual Basic 6 SOAP kit. Naturally, the Web Services model in .NET allows for the consumption of Web Services as well. Web Services should prove to be an exceptionally useful technology in the areas of business-to-business (B2B) communication and commerce, and business-to-person (B2P) commerce.

Caching Services

ASP.NET offers two primary caching techniques: data caching and output caching. Data caching allows programmatic access to a cache store where objects and values can be stored. Output caching allows caching of the output of specific pages for specific periods of time. Previously, the functionality of data caching had to be developed from scratch by the developer, and output caching would also have to be
separately developed and implemented. Naturally, these caching features allow for greater performance advantages.


Security usually plays a large role in a Web application. In ASP, it was up to the developer to implement his or her own security mechanisms, especially in the area of user authorization. ASP.NET features built-in security configuration in its application settings files. This takes a lot of tedious, yet necessary, work off the hands of the developer.

Debugging and Tracing

Every programming environment is constantly striving for better, more advanced, and easier debugging tools and methods. Web application developers have always had to deal with very rudimentary tools, with functionality and usability far behind that of debugging tools for Windows applications developers.

ASP.NET and Visual Studio .NET aim to solve some of these developer woes by providing more advanced debugging tools. Tracing allows developers to inspect and gather important application performance information. Tracing also allows developers to check whether control flow is executing correctly. Developers can now make use of the Output window in VS .NET, a commonly used tool familiar to Visual Basic developers. ASP.NET also provides more detailed and useful error messages, in addition to a .NET stack dump that details the exact steps of the compiler in relation to the classes being used and the methods being executed.


Deployment has traditionally been a huge headache in the Web application development process. Complicated applications required numerous operations to be performed before they would run. Compounding this problem was the requirement of IIS service restarts for updates to business logic components and the mandatory registration of these COM components. ASP.NET no longer uses COM components. Component registration is no longer required. DLLs are no longer locked, and if a component DLL is replaced, all the sessions currently using the old one will continue to use it and all future sessions will use the new one. IIS service restarts are also a thing of the past.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...