Today I was given a VPC image that someone had started and asked to put the WCF REST Starter Kit Hands On Labs on the image so we can use it at Tech-Ed.
I ran into some interesting problems and I thought I would share the solutions with you in case you run into the same thing.
Problem #1 SQL Server Name
The REST Starter Kit labs assume that the SQL Server is “.\SQLExpress”. Normally this works pretty well since Visual Studio installs this instance. However the image I was working with did not have this server present. They had uninstalled it (since it was SQL Server 2005) and replaced it with a SQL Server 2008 install at (local).
I had two choices now. I could go through all the labs and docs and change the connection strings or… I could use a SQL Alias. If you have never used these, they are way cool. SQL Server allows you to create an alias for a server and that is just what I did.
Now I can refer to the server as (local) or as “.\SQLExpress” which means I don’t have to change any scripts, docs or connection strings.
Problem #2 Default.htm is blank
Every now and then I run into something I had never seen before. When I opened Lab 2, I right clicked on default.htm and selected “View in browser” which promptly launched IE and displayed an empty page. I thought that perhaps I had accidentally deleted the content of the page so I opened it in Visual Studio and the HTML was there and displaying properly in the VS Design Mode editor.
I launched the site in the debugger and refreshed IE several times… no luck. I did View Source and saw that an empty HTML was being returned. Now I was really confused. Then I realized that the IIS7 installation allows you to pick and choose features. Once of those features is “Static Content”. I’ve always selected this option and didn’t know what would happen if I didn’t. Sure enough, this option was not enabled. I had to go into Server Manager (on Windows Server 2008) and enable the feature. No big deal but this sure threw me for a minute.
Problem #3 Network Service login to SQL Server
Now that I have the web page showing, I test and get a security exception. The Network Service account doesn’t have permission to open the database. I’m sure that everybody has run into this a dozen times, I know that every now and then I have to fix up a server like this but it seems like I can never remember the exact way to do it. Fortunately my friends in the patterns & practices team have published a great “How to” document on this called How To: Use the Network Service Account to Access Resources in ASP.NET. This document tells me exactly how to grant access.
And now everything is working great for the people who are going to be at Tech-Ed North America 2009.