Category: HowTo

Howto: create a custom httpHandler

If you would like to (for example) make sure all the jpegs on your site are displayed including a copyright text or something like that, you could use the example I posted before. But it would be easier to write a custom httpHandler. Here’s a small howto: 1. Add a class to a WebApplication, and give …

Read More “Howto: create a custom httpHandler”

HowTo: implement a list that sorts based on value ( not key ! )

Sometimes you need a sorted list. You would think in that case the SortedList class would help out, but unfortunately this one only sorts based on the key, while most of the time you would like to sort based on the value.  Now I can almost hear you think: "Why not switch key and value then?" Well, let’s …

Read More “HowTo: implement a list that sorts based on value ( not key ! )”

HowTo: Thread safe singleton implementation of a class

Normally, if you would like a singleton implementation of a class, you would go about it a little bit like this: public class BloggingAbout {     private static BloggingAbout bloggingAbout;         private BloggingAbout()     {     }     public static BloggingAbout BloggingAboutInstance     {         get         {             if (bloggingAbout == null)             …

Read More “HowTo: Thread safe singleton implementation of a class”

Howto: present a Crystal Reports report as a PDF in an ASP.Net web application (without using temporary files)

This one is actually quite simple: Crystal Reports supports exporting to a PDF. Exporting can be done to disk, or to a stream. And a stream can be written to the Repsonse property of a page. And there you go 😉 // Variable declaration   CrystalTest crystalTest;   MemoryStream memoryStream;// Create a new instance of the report …

Read More “Howto: present a Crystal Reports report as a PDF in an ASP.Net web application (without using temporary files)”

HOWTO: display your assembly @ Add Reference

You might want to be able to let your assembly show up in the Add Reference window in Visual Studio without the user having to browse for it. When you install your assembly in the GAC, it doesn’t automatically show up in the Add Reference window, because it doesn’t enumerate all assemblies in the GAC. …

Read More “HOWTO: display your assembly @ Add Reference”

HOWTO: Encode a password using MD5 in C# (or: howto calculate the MD5 hash for a string)

The following method returns the MD5 hash for any given string. For instance for a password. It might be of some assistance when you’re trying to validate user credentials but you don’t want to store the password readable in the database.For this method, you’ll need the following using statements:using System;using System.Text;using System.Security.Cryptography;…public string EncodePassword(string originalPassword){  //Declarations  …

Read More “HOWTO: Encode a password using MD5 in C# (or: howto calculate the MD5 hash for a string)”

HOWTO: Draw your own string (URL, copyright) on each displayed picture in an ASP.Net website

The AdRotator .Net provides can be used to show a different image each time a page is visited. You could write a webpage which does this for you, but it’s probably not very useful. Although you need to change the XML file when changing the images to be showed when you use an AdRotator, but that’s …

Read More “HOWTO: Draw your own string (URL, copyright) on each displayed picture in an ASP.Net website”

HOWTO: create an animated GIF using .Net (C#)

.Net (at least 1.1, they might incorporate it in 2.0) does not give you possibilities to create animated GIFs through GDI+. But there are ways to make them! This solution is one I used myself, and I’m very pleased!//Variable declarationStringCollection stringCollection;MemoryStream memoryStream;BinaryWriter binaryWriter;Image image;Byte[] buf1;Byte[] buf2;Byte[] buf3;//Variable declarationstringCollection = a_StringCollection_containing_images;Response.ContentType = “Image/gif”;memoryStream = new MemoryStream();buf2 …

Read More “HOWTO: create an animated GIF using .Net (C#)”