Exception handling best practices in ASP.NET web applications

Exception handling plays an important part of application management and user experience. If implemented correctly it can make maintenance easier and bring the user experience to a higher level. If not, it can be a disaster.

How many times have you seen the error message that doesn’t make any sense or at least provides some valuable information, or even better – how many times have you seen the famous error screen with exception message and a complete stack trace on yellow background? Too many times, I would say. This is why, among other things, some of my colleagues were very interested in exception handling techniques and best practices.

The goal of this article is to provide an overview of what exception handling is from the user perspective and the perspective of people who maintain the application, and to show the best practices of how to implement useful error handling in ASP.NET web applications. This article is related to my previous articles CSS Message Boxes for different message types and Create MessageBox user control using ASP.NET and CSS since this two articles describes how to show user-friendly messages.

Janko At Warp SpeedException handling best practices in ASP.NET web applications

Google Doctype – Google Code

Google Doctype is an open encyclopedia and reference library. Written by web developers, for web developers. It includes articles on web security, JavaScript DOM manipulation, CSS tips and tricks, and more. The reference section includes a growing library of test cases for checking cross-browser and cross-platform compatibility.

Google Doctype is 100% open.

* Open source
* Open content
* Open to contributions from anyone

Google CodeGoogle Doctype

Emma Alvarez Site: Most Useful 50 CSS Tips And Tools For Webmasters

The style of a website is defined by the CSS. CSS describes text fonts, if images must have borders or shadows, etc. Simply changing the CSS styles, you can change the appearance of your website completely, without changing the contents (text, images…).

For changing the CSS styles, there’s no need to be an expert webmaster, as there are tips and tools that can ease this task.

Here you are a list of the 50 most useful tips and tools for customizing your website easily with CSS.

Emma Alvarez SiteMost Useful 50 CSS Tips And Tools For Webmasters

Powerful CSS-Techniques For Effective Coding | CSS | Smashing Magazine

Sometimes being a web-developer is just damn hard. Particularly coding is often responsible for slowing down our workflow, reducing the quality of our work and sleepless nights with pizza and coffee laying around the laptop. Reason: with a number of incompatibility issues and quite creative rendering engines it sometimes takes too much time to find a workaround for some problem without addressing browsers with quirky hacks. And that’s where ready-to-use solutions developed by other designers come in handy.

Smashing MagazinePowerful CSS-Techniques For Effective Coding | CSS

Create MOSS 2007 Virtual VPC Image

Step by Step understanding of creating MOSS 2007 Virtual PC Image.

Part 1: Getting Started, Installing IIS, and Installing .NET Framework 2.0
Part 2: Installing and Configuring POP3 Email
Part 3: Installing and Configuring Outlook 2007
Part 4: Installing and Configuring the .NET Framework
Part 5: Installing SQL Server 2005
Part 6: Configuring SQL Server 2005
Part 7: Installing SQL Server 2005 SP1
Part 8: Creating the MOSS Accounts
Part 9: Installing and Configuring the MOSS 2007 Application
Part 10: Setting Up Internet Explorer Web Browser Security
Part 11: Starting Services
Part 12: Creating a Shared Services Provider
Part 13: Configuring Search Settings
Part 14: Configuring Outgoing E-mail
Part 15: Creating the Portal
Part 16: Installing SharePoint Designer 2007
Part 17: Installing Office 2007 Applications
Part 18: Installing Warm-up Scripts
Part 19: Optimizing the MOSS 2007 VPC Image
Part 20: Creating a Virtual PC Differencing Disk

ASP.Net, C#, .Net Framework, SQL ServerCreate MOSS 2007 Virtual VPC Image

Secured Subversion on Windows

Recently I decided that I want to move to Subversion 1.1, and have a central repository that manages all my code. The main reason for this was that I got myself a laptop, so having a file-based repository1 that I can access from my laptop.
Being security minded person, I want to tunnel this through SSH, so nobody could look at my valuable code – I’m currently implementing bogo-sort, no less 🙂

Secured Subversion on Windows

Log4net: simple way to use in your Asp.net application

Log the actions of your applications is very important especially when you develop new features or develop very difficult logical business.
But it is also important when users use your applications to understand the critical issues or problems.
To implement quickly the log operations Apache developed an opensource library for .Net developers.

Emanuele’s Blog: Log4net: simple way to use in your Asp.net application

Creating an Outlook Navigation Bar using the ListView and Accordion Controls

Matt Berseth explains how to create an Outlook like navigation pane in ASP.Net with a combination of an Accordion Ajax Control and the ListView control.
Nice example of how the new Ajax controls in the ASP.NET Ajax Control Toolkit can extend the user experience of regular ASP.Net applications with a minimum of code.

One of the designers on our UI team requested a screen mockup with a page layout that is similar to your typical email client. The page is divided vertically into 2 panes. The left pane contains a 2 level hierarchy of categories and subcategories. As the user selects different subcategories the designer wants the right pane’s content to be updated with the corresponding information. Just like Outlook, the designer wants the subcategories to be displayed within expanding and collapsing panels.

Matt Berseth: Creating an Outlook Navigation Bar using the ListView and Accordion Controls

Copy project files to another location after build

For a (web-)project I am working on, I needed to copy the content of 1 website to a sub-folder of another website after the project was built. This enables the 2 projects being separately developed and deployed, but also allows the one project being deployed as a sub-site of the other one. Got it? 🙂

This is how I did this:
In the project file of the sub-project:

  1. In the project file I defined a few variables to make things easier
    <PropertyGroup>
    <MyOutputFolder>C:ProjectOutputFolder</MyOutputFolder>
    <OutputSubFolder>SubFolder</OutputSubFolder>
    </PropertyGroup>
  2. I defined what files to copy, with the binary output (dll) separately from the website content:
    <ItemGroup>
    <MyCopyItems Include="$(MSBuildProjectDirectory)***.aspx" />
    <MyCopyItems Include="$(MSBuildProjectDirectory)***.htm?" />
    <MyCopyItems Include="$(MSBuildProjectDirectory)***.js" />
    <MyCopyItems Include="$(MSBuildProjectDirectory)***.gif" />
    <MyCopyItems Include="$(MSBuildProjectDirectory)***.jp?g" />
    <MyCopyItems Include="$(MSBuildProjectDirectory)***.png" />
    <MyCopyBin Include="$(MSBuildProjectDirectory)bin***.dll" />
    </ItemGroup>
  3. I created a new target that performs 2 copy commands, one for the binaries and one for the content:
    <Target Name="MyPostBuildTarget">
    <Copy SourceFiles="@(MyCopyItems)"
    DestinationFiles="@(MyCopyItems->'$(MyOutputFolder)$(OutputSubFolder)%(RecursiveDir)%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(MyCopyBin)"
    DestinationFolder="$(MyOutputFolder)bin" />
    </Target>
  4. I added this target to the BuildDependsOn property so that it is executed everytime the project is built:
    <BuildDependsOn>$(BuildDependsOn);MyPostBuildTarget</BuildDependsOn>

This gives something like:

<!-- Copy project output to defined folder -->
<PropertyGroup>
<BuildDependsOn>$(BuildDependsOn);MyPostBuildTarget</BuildDependsOn>
<MyOutputFolder>C:ProjectOutputFolder</MyOutputFolder>
<OutputSubFolder>SubFolder</OutputSubFolder>
</PropertyGroup>
<ItemGroup>
<MyCopyItems Include="$(MSBuildProjectDirectory)***.aspx" />
<MyCopyItems Include="$(MSBuildProjectDirectory)***.htm?" />
<MyCopyItems Include="$(MSBuildProjectDirectory)***.js" />
<MyCopyItems Include="$(MSBuildProjectDirectory)***.gif" />
<MyCopyItems Include="$(MSBuildProjectDirectory)***.jp?g" />
<MyCopyItems Include="$(MSBuildProjectDirectory)***.png" />
<mycopybin include="$(MSBuildProjectDirectory)bin***.dll" />
</ItemGroup>
<Target Name="MyPostBuildTarget">
<Copy SourceFiles="@(MyCopyItems)"
DestinationFiles="@(MyCopyItems->'$(MyOutputFolder)$(OutputSubFolder)%(RecursiveDir)%(Filename)%(Extension)')" />
<Copy SourceFiles="@(MyCopyBin)"
DestinationFolder="$(MyOutputFolder)bin" />
</Target>

Some references on copying project files with MSBuild:
MSDN MSBuild Reference – Copy Task
Channel 9 Wiki: Copy Built Output Of A Visual Studio Project
SharpDevelop Community – Copy config post build
How To: Insert Custom Process at Specific Points During Build
How To: Add Custom Process at Specific Points During Build (Method #2)

[Build Knowledge] Versioning

Today I’ll show you how to use NAnt and Cruise Control.Net to Version your application.
What you’ll need
1. NAnt A .Net Build tool. We’re going to use this to compile our Hello World Application and set the version number.
2. Cruise Control.Net A Continious Integration Server that lets us start NAnt and makes our version number.

Sleep Overrated – Scott Cowan[Build Knowledge] Versioning