Writing to the Windows 2000 Event Log is a powerful feature of the ASP.NET and .NET framework. For those individuals who work in a large company and want to make track application errors, writing to the event log is a must!Writing to the Windows 2000 Event Log is a powerful feature of the ASP.NET and .NET framework. For those individuals who work in a large company and want to make track application errors, writing to the event log is a must!There wasn't any complete demos actually showing from A - Z how this was setup for the novice/common developer like me. Most novice developers need to be spoon fed how things are done the first time, once they see a simple example, they'll understand how the process works! This example is my reference how to make a complete application from A - Z setup and fail to understand how it works.[bold]Step 1[/bold]First of all the steps I followed was to create a simple web called eventlog. I also created the application root so the global.asax file would fire.Here is how to setup an application root:[bold]1.[/bold] Open Internet Service Manager MMC[italic](Start button, Control Panel, Administrative Tools, Internet Service Manager)[/italic][bold]2.[/bold] Located on the left side of the MMC, locate the Default Web and click the + buttonto expand the list of webs. [bold]3.[/bold] Right-click on the web your going to make an application root and choose properties.[bold]4.[/bold] Click the Create button.[bold]5.[/bold] After your done, the folder picture will appear like a box that is open. The application root is now created.[bold]Step 2[/bold]I opened the global web.config file and turned on custom errors. Path to this is c:\winnt\microsoft.net\framework\.. There are 3 choices available currently On, Off and RemoteOnly. From attending the conference, the recommended was RemoteOnly. This means anyone not on the console of the machine will see a friendly error and not the real thing. For this example I chose On. You also could leave the global web.config file custom errors turned off and configure at application level's web.config Either way works just fine.[bold]web.config -- this file is placed in the root of the \eventlog application root.[/bold]
[bold]Step 3[/bold]The next few items are just to create sample pages to make the application complete. I created a web.config, global.asax, Default.aspx page, and three sample error pages. 404page.aspx, 403page.aspx and customerrorpage.aspx page.Here are those pages code for all pages.[bold]Global.asax Page - This uses the Application_OnError event to capture stuff if an error happens[/bold]
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Diagnostics" %>
[bold]Default.aspx page[/bold]
<% @Language="VB" %>
[bold]Step 3[/bold]The next few items are just to create sample pages to make the application complete. I created a web.config, global.asax, Default.aspx page, and three sample error pages. 404page.aspx, 403page.aspx and customerrorpage.aspx page.Here are those pages code for all pages.[bold]Global.asax Page - This uses the Application_OnError event to capture stuff if an error happens[/bold]
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Diagnostics" %>
[bold]Default.aspx page[/bold]
<% @Language="VB" %>
No comments:
Post a Comment