Two C# Guys

Wednesday, November 16, 2005

Planning

Here's something that Martin Fowler recently wrote in his bliki about why planning is so important:
You can't put ten pounds of shit into a five pound bag

--Anyone who has tried

I thought it was a good way of summing things up.

Saturday, November 05, 2005

Registering IIS with ASP.Net

Here's a command I have trouble remembering, but find myself needing on a few occasions. If you ever need to register or re-register ASP.Net on IIS, use this command:

C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis -r

You'll know you need to do this if you've installed the .Net Framework and IIS complains that it doesn't know what the heck to do with all those aspx pages.

Saturday, October 29, 2005

Update on Encryption

Ok, I just read my post on Windows XP Encryption and .Net. You can get it to work. I discovered this when I was using SQL Server and I placed my data in an encrypted folder. The trick is to change the service login from 'LocalSystem' to whatever login you were using when you encrytped the folder. There are some security concerns doing this, but it does demonstrate that you can use Windows XP encryption and still get your work done.

Virtual Machines

We've been using virtual machines quite a bit in the office for our development work. They come in really handy when we need to host an application that is under development and we don't have spare server around.

Here's a great article that shows how to create a Windows XP VM using QEMU and VMWare player, which both happen to be free.

Been a while ...

It has been a while since Russ or I posted anything to this blog. We were completely tickled when we saw that Scott Hanselman had commented on one of our posts. Afterwards, we were motivated to blog more often.

Monday, June 21, 2004

Navigation in ASP.Net

Here's a great article on the differences of navigation using Hyperlinks, Response.Redirect, Server.Transfer(), and Server.Execute().

ASP.Net: Server.Transfer() and "Thread was being aborted."

I recently ran into something that was beginning to ruin my day. Check out the following snippet of ASP.Net code:

private void Page_Load(object sender, System.EvenArgs e)
{
   try
   {
      // (Do some stuff, then ... )
      Server.Transfer("AnotherPage.aspx");
   }
   catch (Exception ex)
   {
      throw new Exception(ex.Message, ex);
   }
}

Looks innocent, right? Wrong!

Here's what's wrong. When the Server.Transer() is executed, the catch clause catches the following exception: "Thread was being aborted." And if you have a custom error page it will catch that exception every time you do a Server.Transfer().

One suggestion, which worked for me, is to use Server.Execute() instead of Server.Transfer(). The main difference is that Server.Transfer() terminates execution of the current page (which is what causes the exception), and Server.Execute() executes the specified page and then returns control to the current page, much like a function call. There are other differences, but I'm not going to get into them here. Suffice to say, that Server.Execute() won't cause the "Thread was being aborted" exception to be thrown.

Cheers.

Monday, June 07, 2004

SharpToolbox

Need a development tool, add-in or library for .Net? Check out SharpToolbox. They currently have over 500 such tools listed.

Sunday, June 06, 2004

ASP.Net, MSDE, and Windows XP Encryption

When it comes to .Net and Windows XP Encryption, don't do it.

Here at work we are very concerned about data security. A recent issue that came up was the security of business data that was stored on laptops and home computers.

In the past, I would archive the files I need and copy them onto a USB key or CDRW so I could bring them home and work on them. Then, when I'm ready to work at home or on my laptop, I restore the archive to my hard drive and I'm good to go.

In an attempt to be a 'secure' employee, I began password protecting my archives. Winrar is a really good tool for this, since it also 128-bit encrypts the entire archive when it is password protected. Then, using Windows XP file encryption, I encrypted my working folder. Here's where the problems started.

First, MSDE (MS SQL Server Developer Edition) could not read the encrypted data files. I thought perhaps SQL Server had just gotten confused, so I detached the database with the attention of attaching it again. However, SQL server could not attach to the encrypted database (if I remember correctly, it told me that it was an invalid .mdf file). As soon as I unencrypted the data files, SQL Server attached it without complaint.

Second, when I tried to run my ASP.Net application, I kept getting an error that said access was denied to one of the assemblies that I had written. It turned out that it couldn't read the encrypted .dll files. Once I unencrypted my work folder, everything worked out great.

So, to sum it all up, when you are working with MSDE and ASP.Net, don't use Windows XP file encryption.