• Increase font size
  • Default font size
  • Decrease font size

How to add simple Error logging to an ASP.NET application

E-mail Print PDF

When building an enterprise application, many would recommend using Microsoft's Enterprise Library for error logging.  If you are already using Enterprise Library in your application, then you may want to go that route.  For applications where simple error/exception logging is needed, I would personally recommend using ELMAH (Error Logging Modules and Handlers for ASP.NET).  Adding ELMAH to your application is very simple to do, and gains you the following features:

  • Logging of nearly all unhandled exceptions.
  • A web page to remotely view the entire log of recoded exceptions.
  • A web page to remotely view the full details of any one logged exception, including colored stack traces.
  • In many cases, you can review the original yellow screen of death that ASP.NET generated for a given exception, even with customErrors mode turned off.
  • An e-mail notification of each error at the time it occurs.
  • An RSS feed of the last 15 errors from the log.

Here I will walk you through quickly adding ELMAH to your application.  For this example, I will be logging errors to a Microsoft SQL database table, but the tool is configurable to several different datasources (MS SQL, MS SQL CE, MS Access, Oracle, SQLite, XML Files, MySQL, PostgreSQL).

  1. First, download the Core Binary and MS SQL Server DDL Script from the project website.
  2. Now you will need to execute the DDL script against your application's database (or a different one if you desire).  This script will create the logging table and a few stored procedures.
  3. Next, extract the Core Binary .zip file and drop the Elmah.dll file into your website's Bin directory.
  4. Now you will add a few lines to your application's web.config (see images below).  This configures ELMAH to log application execeptions.
    web config entries
    elmah web config entries
  5. In this case, I didn't want all site users to be able to view the error log.  So, I added the following to a web.config file in the /Admin directory of my application.  If you wanted all users to access the error log, you would put this in your root web.config file.
    elmah web config entries

Now to view your errors you would view the page http://[websitename]/elmah.axd (even though this file does not physically exist).  In this case, I wanted the errors viewable only to admins, so the URL would be http://[websitename]/admin/elmah.axd.  Here is a snapshot of the error page you will see:

elmah error page example

There you have it.  Simple Exception logging for your ASP.NET site using ELMAH. 



Last Updated on Tuesday, 02 August 2011 18:48

How to add an image to Word Press Blog posting

E-mail Print PDF

This may be old news to someone experienced with CMS and websites, but for someone new to blogging, this information may be helpful.  Many people who blog may create the content locally on their PC, in Word for example, and then paste the information into the blog.  This works great to capture text and basic formatting, but if you have images, you may wonder why those images don't display. 

In short form, the answer is that you have to upload images to the blog site before you can use them.  The steps listed below will help detail how to accomplish this...

  1. Once you are in the editor to write or edit a post, click the "Add an Image" button.
    add wordpress image
  2. Now you will select the image stored on your computer.  First click the "Browse.." button and locate the image on your PC.  Next, click the "Upload" button to load it to the webserver.
    upload wordpress image
  3. After hitting "Upload" a new screen will appear. Here you can provide a title for the image file, a caption (used by screen readers), and a description.  You can also choose how the image will be aligned in your article and its size.  After making your edits, click "Insert into Post".  This will add the image to the article you currently have open.
    insert wordpress image to article
Last Updated on Tuesday, 05 July 2011 14:27

Firefox 4 is out! Get Some!

E-mail Print PDF

jQuery Error in ASP.NET website

E-mail Print PDF

I felt it necessary to share this information in hopes it saves someone else time and hassle.  I was recently working on an ASP.NET website for a client that made use of jQuery and jQueryUI.  The site worked fine when I referenced the jQuery files on the CDN (see Snippet 1 below).

Code Snippet 1.

javascript cdn reference

There were concerns about the website linking to externally hosted scripts, so I needed to download and reference the jQuery files (jquery-1.4.4.min.js, jquery-ui-1.8.7.custom.min.js) locally.  When I would reference the jQuery files locally (see Snippet 2),

Code Snippet 2.

javascript local reference

The site would break and produce the following error:

Microsoft JScript runtime error: object expected

I found many references to this error when searching the net, but they all referenced the PATH of the jQuery files and making sure it was correct.  I saw many solutions to map the PATH at run time, but no matter what the error persisted. From all the forum posts I read, it seems like many others could not resolve their issue unless they reference the files on CDN (Snippet 1 above).

After I realized the issue I had, it was obvious, but it took my some time to come to this conclusion.  I was restricting site access to unauthenticated users and redirecting to a login page (the login page was using jQuery functionality).  Using the ASP.NET Configuration tool, I blocked access to all site files except the login page (web config entry below).

This in effect was restricting access to the local jQuery files when an unauthenticated user visited the login page, causing the "object expected" error.   The solution to this is granting access to the directory holding the scripts.  I accomplished this by creating a new web.config file with the text below and placing it in the scripts directory.   

It is also noteworthy to mention the same condition can apply if you are using master pages and external CSS files.  If your login page references these items, anonymous users must have access to them.  I hope I am able to help someone out by posting this article.  If you have any questions, feel free to post them in the comments below or in the forum.  Good Luck!
Last Updated on Tuesday, 02 August 2011 18:47

Awesome free new resources for learning about Linux!

E-mail Print PDF

We are proud to offer a large new selection of FREE eBooks for those interested in Linux.  If you are just getting started or looking for more advanced information, we have you covered!

Learn the basics of the Linux operating systems. Get to know what it is all about, and familiarize yourself with the practical side. Basically, if you're a complete Linux newbie and looking for a quick and easy guide to get you started this is it.  Get it here
Slackware Linux Essentials is an indispensible resource that you will want to have by your side at all times. It contains the most complete and up-to-date information available on the Slackware Linux Operating System.  Get it here
A comprehensive collection of Linux security products and explanations in the most simple and structured manner on how to safely and easily configure and run many popular Linux-based applications and services.  Get it here
In this ebook "The GNU/Linux Operating System", the main contents are related with system administration. You will learn how to install and configure several computer services, and how to optimize and synchronize the resources using GNU/Linux.  Get it here

Page 3 of 20

Recommended Web Hosting

Free Stuff!

Featured FREE Resource:

Featured FREE Resource: