Justin Cooney

Web Development Tips and Examples

  • The other day I was working on a Windows 2003 SP2 server that was no longer displaying anything other than the Windows desktop. I could not bring up the start menu or even see the bottom menu bar.  This naturally was a problem because I wanted to set up a new Web site on the server.

    In my experience this problem with Windows is most likely caused by Windows running for too long without a restart, so the standard fix is typically to restart the entire computer.

    However, restarting the server was not an option since at that time it was being actively used by other developers for development and testing. So rather than cause trouble for everyone, I decided to look into setting up desktop shortcuts to the programs I wanted to work with.

    (more…)

  • I have been working with ASP.NET collections and thought a more detailed look into one of the most useful classes also know as the Dictionary collection object is in order.

    To review: the Dictionary class is part of the System.Collections.Generic Namespace. If you haven’t already, then it’s worth having a look at the list of collections contained in the namespace to become familiar with the various collections options available to you. The main benefit of the using collections from the Generic namespace is that the collections are strongly typed, giving you better performance and type safety.

    The Dictionary collection stores key – value pairs much like a Hashtable from the System.Collections Namespace.  However where a Hashtable has an inbuilt re-ordering system based on your provided keys, the Dictionary collection works on a First-In-First-Out (FIFO) basis. This can be a real boon if you want key value pairs that don’t get randomly re-arranged. The Dictionary object is not documented to be FIFO, but it has been working this way since .NET 1.1 so I hope that this will continue to be the case. Similar objects to the Dictionary class are the SortedList and the SortedDictionary classes, but these do have inbuilt sorting similar to the Hashtable’s sorting, so they are only situationally useful.

    In addition to the Dictionary object, I like to use ArrayLists and string arrayx. So as part of my example code I show how to store a  String array inside a Dictionary object as the value. This can be quite useful in a number of ways depending on your goals, but the flexibility this method offers is something to keep in mind.

    If you are interested in reading the API for the Dictionary object then I definitely recommend reading the official Microsoft Documentation. An interesting point that’s covered by the  documentation is that using TryGetValue is the most efficient syntax to use rather than ContainsKey or ContainsValue.

    (more…)

  • In an earlier article I covered how to generate Excel reports on the fly using the Interop.Excel Namespace.

    This is a really handy technique that also gives you full control over the minutia of the document you are creating. However the catch in using this technique is that you will need to update the configuration of your Web server to allow Web users to trigger Excel on your Web server. This can mean some pretty drastic security changes and possible loopholes in your Web server’s security so you should do a risk analysis before choosing this method.

    In this article I will review the Web server security updates that need to be made to allow using the Interop.Excel Namespace to generate Excel documents for your Web site.

    Please note that since I am developing this site for an Intranet, I am not as concerned with locking down the server. If you are working with a server that is exposed to the Web then you will want to review these security changes much more thoroughly.

    (more…)