TAILIEUCHUNG - Professional ASP.NET 1.0 Special Edition- P22

Professional Special Edition- P22:Those of us who are Microsoft developers can't help but notice that .NET has received a fair amount of visibility over the last year or so. This is quite surprising considering that for most of this period, .NET has been in its early infancy and beta versions. I can't remember any unreleased product that has caused this much interest among developers. And that's really an important point, because ignoring all the hype and press, .NET really is a product for developers, providing a great foundation for building all types of applications | LogName Message End Sub script In the above example we first Import the namespace since we will be using some of the classes found in this namespace to write to the event log. We then implement our Application_Error event handler and create some local variables before using the EventLog class s static method SourceExists to determine if the event log we re going to write to already exists - if it doesn t we create it. Finally we create a new EventLog instance named Log and use the WriteEntry method to enter our Message into the Windows Event Log. Whenever an error occurs within our application that error is now logged into a custom event log named Web_Errors. It should be noted here that we wrote little more than 10 lines of code to accomplish a task that could potentially be 50 to 60 lines in VB ASP. Now that we have covered each of the application events let s look at some advanced topics. These are areas that are left to the more advanced developer and the understanding of these topics is not required to build great applications but they do help Advanced Topics In this Advanced Topics section we will cover four advanced topics related to building superior applications Using static variables - It is not necessary in all cases to use Application to store persistent values in memory. Since is compiled and the application is represented in an object-oriented manner we can use global static variables in addition to Application. Using our own base class for - The earlier discussion of the Application directive for mentioned the Inherits attribute. We will examine how we can use this to create our own class for to instantiate. Mapping file extensions - If we want to support file extensions other than the defaults such as the file extension .wrox we must map the extension in IIS first. This is because IIS gets the first look at

TỪ KHÓA LIÊN QUAN
TÀI LIỆU HOT