Add Application Extension in IIS
Earlier tonight, I was trying to setup a new file extension for a web application using IIS. The idea was simple enough. Default Website | Home Directory | Configuration | Application Configuration.
I tried clicking the Add button to add an extension, but when I did the OK button was always disabled. No matter what, I could not get it to enable.
This is one of the sillier workarounds I’ve seen in a while. After selecting the executable, you need to click on the textbox itself and the path will fully expand, enabling the OK button so you can save the mapping.
Steve Jobs’s Commencement Address at Stanford
Steve Jobs’s 2005 commencement address at Standford is a message of hope. The address is outstanding and should be read by everyone.
“You’ve got to find what you love. And that is as true for your work as it is for your lovers. Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven’t found it yet, keep looking. Don’t settle. As with all matters of the heart, you’ll know when you find it. And, like any great relationship, it just gets better and better as the years roll on. So keep looking until you find it. Don’t settle.”
Custom Configuration Sections in Beta 2
I spent a little time this afternoon delving into Whidbey Beta 2, after finally surfacing from other priorities at work.
One of the things that I’ve been really interested in is the Provider pattern, and so I decided to start understanding a little more how this pattern works in Whidbey. I’ve used this pattern quite a bit in .NET 1.1, however, the nice thing about 2.0 is that a lot of the base classes are already there for you.
As I was investigating further, there was one thing that really caught my eye. This was the new Configuration mechanism which you can use to create your own custom configuration sections. You know have the option to do this all declaratively (by deriving ConfigurationSection), instead of manually parsing the XML like you did with 1.1.
As I was looking through some of the pre-built ConfigurationSections, in my mind, there was one that was conspicuously missing considering the emphasis of the Provider pattern in .NET 2.0 and that was a Provider section.
What I hoped for was a class that would allow me to declare a section that looked something like this:
<sectionName defaultProvider=""> <providers> <add name="" type="" /> </providers> </sectionName>
Unfortunately, I did not find one, so I wrote one out. This also helped me to understand the new configuration mechanism, and saves me from having to re-implement the same logic for any other providers I may author in the future.
Take this code:
public class ProviderSection : ConfigurationSection { private readonly ConfigurationProperty defaultProvider = new ConfigurationProperty("defaultProvider", typeof(string), null); private readonly ConfigurationProperty providers = new ConfigurationProperty("providers", typeof(ProviderSettingsCollection), null); private ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection(); public ProviderSection() { properties.Add(providers); properties.Add(defaultProvider); } [StringValidator(MinLength = 1)] [ConfigurationProperty("defaultProvider")] public string DefaultProvider { get { return (string)base[defaultProvider]; } set { base[defaultProvider] = value; } } [ConfigurationProperty("providers")] public ProviderSettingsCollection Providers { get { return (ProviderSettingsCollection)base[providers]; } } protected override ConfigurationPropertyCollection Properties { get { return properties; } } }
Immediately, you should notice the two attributes on the DefaultProvider property. The ConfigurationProperty attribute denotes which attribute should be used for loading the property, and the StringValidator attribute insures that the attribute is at least one character long. How cool is this? To write something like this in 1.1 would have taken easily 3 times as much code.
No more stored procedures…YAY!
During a recent upgrade to an application Ive been working, all but one of the stored procedures was removed.
What?!?! Indeed, data access can happen without stored procedures, and as referenced in some other weblog posts this may be very advantageous. Go ahead and read this post (stored procedures are bad, m’kay?) now… I’ll wait.
In the case of this particular application, there was always an issue about keeping three different projects in sync (the DAL, the database project, and the installer project).
Any time that I needed to make a change to retrieve additional data from a table in the application’s database, I had to make changes to three projects. First off, I had to update the database project to modify the stored procedure. Once that modification was done, I was able to modify the Data Access Layer to use the new field. Finally, when everything was done, I needed to remember to update the installer project so that the scripts that create and update the database have the correct stored procedures.
Now, as you can see this can cause quite a bit of headache and an update process that can be very prone to error. The way that I found to get around this is to move all but the most complex stored procedures (the ones that were actually performing real work) into the DAL directly.
What this means is that instead of having a stored procedure that does ‘SELECT * FROM Users’, I send that command directly to the SQL database using the SqlCommand object in the .NET framework. The technique is identical to what is used to execute the stored procedures.
One thing that I hear quite a bit is that you open yourself up to Sql injection attacks when using dynamic sql, instead of stored procedures, because you can not use parameters. This is completely wrong. Let me show an small working example:
SqlCommand cmd = new SqlCommand("select * from users where UserName = @UserName"); cmd.Parameters.Add("@UserName", SqlDbType.VarChar).Value = someUserNameVariable;
You see here that you have exactly the same parameter semantics as you do using stored procedures. These semantics allow you to pass values into the parameter object where they will be scrubbed to make sure that no sql injection attacks can take place.
Using dynamic sql in the data access layer, if I want to update the columns that are pulled back, I no longer have to modify a stored procedure in the database project. Also, I dont have to modify the installer project, because all of my sql is right where it belongs… in the data access layer.
Official VS.NET 2005 Launch Date
As part of the keynote address, Paul Flessner, senior vice president of Server Applications at Microsoft, showed the company’s continued momentum in preparation for the launch of SQL Server™ 2005, Visual Studio® 2005 and BizTalk® Server 2006, and announced that these products will be formally launched during the week of Nov. 7.
via microsoft.com
Disabling the system beep
This came through an an email thread this afternoon and I thought Id share this with the rest of you.
Under Virtual Server, there are a lot of annoying beeps that occur as some sounds appear to beep (since there is no sound support under Virtual Server). Turning it off is fairly straight-forward if this beep drives you bonkers (as it does me).
- Open up Device Manager on the host machine (the one that you are using to control the virtual server).
- From the View menu, select ‘Show hidden devices’.
- Expand ‘Non-Plug and Play Drivers’.
- Right-click ‘Beep’ and select ‘Properties’.
- Select the ‘Drivers’ tab.
- Click ‘Stop’.
You can also change the startup type to ‘Disabled’, so that the beep service never starts.
This is a great tip… Thanks, Jay!


