Tuesday, January 22, 2008

How to create a machinekey for your web.config

Issue: I'm trying to make the session persistent across two applications. The key is to set the machinekey in the web.config under .

I didn't know how to figure out or create my machinekey without getting involved in more code. I figured there had to be a quick way, a way that wouldn't put me on a tangent. Then, I found it.

Go here to produce your own .net 1.1 and .net 2 keys
http://www.developmentnow.com/articles/machinekey_generator.aspx

Wednesday, January 16, 2008

C# SQL2005 money and displaying it

Quick note:

I'm retrieving a money value from a sql server 2005 database. When walking through the reader, I want to display the dollar amount formatted correctly. But, it keeps coming up incorrect. For example: 200.00000 instead of $200.00.

Solution:
I was looping through the reader, converting the value to a string then trying to format it. I took out the .toString() and it worked fine.

correct usage:
String.Format("{0:c}",reader["dollarvalue"])

Also, if we are prefilling a text box, we do not want to show the $ sign. So, we use a different format:
String.Format("{0:f}", reader["dollarvalue"])

Monday, January 7, 2008

Issues starting IIS

This morning, I restarted my computer, tried to browse to a local site for programming and it wouldn't start. Went to IIS to check it out, I noticed it wasn't started and had a red stop sign on the directory of sites. I tried to start it and this is the message I saw:

unexpected error 0x8ffe2740 occurred

Nice, well, I checked the MS online docs and it told me I had another application using the same port. I downloaded tcpView to see which application it could be. TCPView couldn't tell me initially what it could be based on ports. It turned out, that if i stopped Skype, I could restart IIS.

So, resolution, start IIS before Skype, and/or change port settings for Skyp.