Posts
22
Comments
681
Trackbacks
9
December 2007 Blog Posts
A (re)fresh Start

After a painful hard drive crash in my laptop I finally extended my home network and added a dedicated server machine with a RAID5 disk array to minimize future data loss from hard drive failure. This also allowed me to finally separate the web serving duties from my gaming rig, but it caused a couple of days of downtime for my blog while I was juggling hardware and reassembling and reinstalling the machines. Now everything is done and up and running again. And I think the only people who noticed that the blog was down were probably the comment spammers anyway ;-)

I am running Windows Vista Ultimate 32bit on my file server and Windows Vista Ultimate 64bit on my gaming rig. While this might seem a bit reverse it makes sense for me, since my gaming rig is also used for software development and 3D rendering jobs, and it has 4 GB of RAM as opposed to the 2 GB my file server has. Also, it makes automatic processing of recorded TV shows on my file server easier, as I use the excellent and free DVR-MS Toolbox software to automatically detect commercials for me.

That is also the reason why I am running Windows Vista and not Windows Home Server on my file server, since Windows Home Server is lacking any Media Center functionality which is crucial for me since I am using my file server with my Xbox360 Media Center Extender to play back recorded (commercial-free) HDTV programs.

I called this blog post A fresh Start because I am also getting back to the roots of why I started blogging in the first place. After my first (surprisingly popular) posts about different Subtext configuration scenarios on Windows Vista and IIS7 I fell into the habit of rehashing news from other blogs without adding a lot of value to it. Back in March I wrote a blog post about Upcoming Articles, unfortunately none of which ever got written. The problem was that I wanted to produce more content then I had time for while trying to match (or excel) the quality level of people that get paid to blog all day long.

Now, 9 months later, some of the beta products I wanted to write about such as Windows Home Server and Visual Studio 2008 have been released as final products already, and I better leave it to people such as Paul Thurrott to review and write about them in a more timely manner. I have been working on some of the programming projects I announced back then, but with a full-time job and family & friends I simply haven't had the time yet to bring the results into a format that others can understand and use.

So I am taking a fresh stab at my blog by doing what I did in the beginning: When I hit a problem that I cannot find a solution for on Google and I manage to solve it, I will blog about it. Consider this my mission statement! I had such a case today with my latest blog post about Virtual Server on Vista. If I don't have anything to write about in a couple of months, then I won't talk about things you can find on any other blog already. Most people find my blog through keywords and Google anyway, which means I don't expect anyone to ever hit this post and actually read it :-) It is more of a reminder to myself and a marker in time in case I look back at some point in the future and wonder what I have been thinking about.

Enough said, see you when I solve the next problem!

posted @ Tuesday, December 11, 2007 1:34 AM | Feedback (7)
Configuring a separate Virtual Server Administration Web Site with IIS7 on Windows Vista

I installed the freely available Microsoft Virtual Server 2005 R2 SP1 Enterprise Edition on my Windows Vista machine today and noticed that the setup did not let me add the Administration Web Site for Virtual Server on a different web site than the default web site. Instead the only option was to have it added as a virtual directory to the default web site running on port 80. However, I expose the default web site to the outside world (as a matter of fact I run this blog off that machine), so I did not want to have the virtual directory for my Virtual Server exposed to the outside world as well. Since I couldn't find anything on Ben Armstrong's blog about this I decided to share my findings here.

So what does it take to configure IIS7 on Windows Vista to have the Virtual Server Administration Web Site in a separate web site and a different port? Follow these simple steps:

  1. First of all, make sure you are running one of the supported editions of Windows Vista. Basically the Starter and Home editions don't even let you install IIS7, and Home Premium does not support Windows Authentication, so only the Business, Enterprise, and Ultimate editions have the required features.
  2. Before installing Virtual Server, you need to enable the right options for IIS7 in Control Panel -> Programs and Features -> Turn Windows Features on or off. See this post on Ben Armstrong's blog for details on which options need to be installed.
  3. Execute the Virtual Server installer.
  4. Open the Internet Information Services (IIS) Manager from Administrative Tools.
  5. You will see that a virtual directory called VirtualServer has been added underneath your Default Web Site. Right-click on the parent folder of the Default Web Site called Web Sites and select Add Web Site...
  6. Fill in a name. I used Virtual Server, but you can pick any name you want. You can use the DefaultAppPool with the web site, or you can create a separate app pool if needed. However, since the Virtual Server web site is CGI and not ASP.NET, I believe it does not make much difference either way.
  7. The Physical Path should point to C:\Program Files\Microsoft Virtual Server\WebSite or whichever directory you installed Virtual Server into. Make sure it points to the WebSite subfolder.
  8. Pick a port other than 80, so that the web site cannot be accessed from the outside world. If you want to expose the web site to the outside world, you should still pick a port that cannot be easily guessed by a stranger for security purposes. Even if someone guesses the right port the web site will not be completely exposed, since Windows Authentication will require correct credentials to display the web site. By default, the Virtual Server setup will use port 1024 if it creates a separate web site automatically (presumably on a Windows Server 2003 system).
  9. If you are not exposing the web site to the outside world, simply enter localhost as the Host header, otherwise enter your desired Host header. If you want to access the administration web site from a different computer within your network, make sure to also add a second binding to the actual host name of the machine.
  10. Leave the Start web site immediately checkbox checked and click Ok.
  11. Now click on the web site you just created in the web sites tree so that the configuration icons for the web site appear in the IIS management console. You can ignore the ASP.NET configuration settings, since as I said before already this is not an ASP.NET application.
  12. Open the Authentication configuration settings and disable everything except Windows Authentication.
  13. In Handler Mappings, make sure CGI-exe is enabled. If it is not enabled, right-click on it and select Edit Handler Permissions, then check all permissions, in my case Execute was unchecked and needed to be checked.
  14. Done!
  15. Open a browser and test your configuration by navigating to http://<hostname>:<port>/. If you entered localhost in step 9 and for example port 1234 in step 8, the address would be http://localhost:1234/. The Virtual Server Administration Web Site should come up successfully.
  16. You can now remove the virtual directory that was created by the setup from your default web site.

 

Troubleshooting:

  • If you open the web site in your browser and it offers you the CGI application as a download, you did not enable CGI execution on the web site. Make sure you followed steps 2 and 13 above.
  • If the administration web site comes up but says "Could not connect to Virtual Server. Access Denied. Please contact Virtual Server administrator to set the required permissions to manage Virtual Server.", then you did not enable Windows Authentication. Make sure you followed steps 1 and 12 above.
  • If you get a HTTP 400 Bad Request error in your browser, you probably didn't set up the host header for the web site correctly. Make sure you followed step 9 above.
posted @ Tuesday, December 11, 2007 12:57 AM | Feedback (15)
Debugging Subtext on Windows Vista using IIS7 and Visual Studio 2005

This post describes how to compile and debug a web application using IIS7 instead of the built-in web server that comes with Visual Studio 2005. The built-in server should work right out of the box without any further configuration. While this post can pretty much be applied to any ASP.NET web application, I am writing it specifically for the source code of the open source blogging engine Subtext and as a third installment on my blog posts about how to install Subtext on Windows Vista and IIS7. Most people that set up Subtext on a machine are likely to compile the source code at one point or another, especially if you want to make changes to your page template and use user controls (as I did for my Technorati and Flickr controls). For the remainder of this post I assume that you already have successfully set up the compiled binaries for Subtext and the database mainly so that I don't need to reiterate certain necessary installation steps.

There are plenty of resources online that describe how to create/debug web applications using Visual Studio 2005 on IIS7. The two most important things you have to keep in mind are:

  1. To debug web applications you need to start Visual Studio 2005 with the "Run as Administrator" option from the right-click context menu.
  2. For debugging to work you need the IIS 6 Metabase and Configuration Compatibility components installed (which should already be the case if you set up IIS7 to work with SQL Server 2005).

Update 12/10/2007: As pointed out in some of the comments, IIS7 does not have the same functionality on all editions of Windows Vista. See this post for details. Basically the bottom line is that you won't be able to get it running on the Starter, Home, or Home Premium editions of Windows Vista because the authentication portion cannot be configured as required. The Business, Enterprise, and Ultimate editions will work fine.

For the Subtext solution the same applies as for the binaries when setting up the Virtual Directory, meaning you have to make sure the application pool is set to Classic .NET AppPool. Also, the project properties for the Subtext.Web project have to be changed from Use Visual Studio Development Server to Use IIS Web server. It is okay to let Visual Studio 2005 create the Virtual Directory for you using the Create Virtual Directory button (note: If you are not executing Visual Studio 2005 with elevated rights, you will get an error message when trying to create the Virtual Directory), but again you will have to change the application pool if the default app pool is not set to Classic .NET AppPool. Now when you start debugging the application here are some common error messages you might encounter and how to resolve them. If anyone gets any other errors please let me know and I will add them to the list (with solution if available):

Message: "Unable to start debugging on the web server. The web server is not configured correctly."
Solution: Unfortunately this is one of the most vague errors you can encounter. Microsoft recommends executing the web site in non-debug mode so that you get to see the underlying IIS error message. Check to see if that message is listed below to resolve it. If there is no error when executing in non-debug mode, make sure that debug is set to true in the Web.config file like this: <compilation debug="true" defaultLanguage="c#">. Alternatively this can also be set in the .NET Compilation settings in IIS Manager.

Message: "Server Error in Application "Default Web Site". HTTP Error 404.0 - Not Found"
Solution: This message comes up if you don't even have the Virtual Directory set up. Set up the Virtual Directory and make sure the application pool is set to Classic .NET AppPool.

Message: "Unable to start debugging on the web server. Debugging failed because integrated Windows authentication is not enabled."
Solution: On the Authentication dialog in IIS Manager enable Windows Authentication and disable Forms Authentication. You cannot have both enabled at the same time.

Message: "An exception of type 'System.InvalidOperationException' occurred in System.Xml.dll but was not handled in user code. Additional Information: There is an error in the XML document."
Solution: This exception is thrown in XmlSerializerSectionHandler.cs when deserializing the blog configuration section from Web.config. When making changes to Web.config through the IIS Manager it seems to clear out the values in the BlogConfigurationSettings section, so I had to fill in the values for all configuration parameters in the section again. These are the default values:

<!--
Checkout Subtext.Framework.Security for hashing passwords.
This should be set when first installing the application
and really shouldn't be changed afterwards.
-->
<UseHashedPasswords>true</UseHashedPasswords>

<!-- Globally control access to web services -->
<AllowServiceAccess>true</AllowServiceAccess>

<AllowImages>true</AllowImages>

<!-- Globally control use of XHTML -->
<UseXHTML>true</UseXHTML>

<!-- Default Item Count -->
<ItemCount>25</ItemCount>

<!-- Default Number of Posts to Show on Category Pages. Use 0 to show all. -->
<CategoryListPostCount>0</CategoryListPostCount>

<!-- Default Server Time Zone Offset -->
<ServerTimeZone>-8</ServerTimeZone>

<!-- Whether or not to GZIP the RSS and/or atom feeds. -->
<UseSyndicationCompression>true</UseSyndicationCompression>

Message: "An exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll but was not handled in user code. Additional information: An error occurred creating the configuration section handler for BlogConfigurationSettings: There is an error in the Xml document."
Solution: This message appears as a follow-up error of the previous message. When the previous one is fixed this should go away as well.

posted @ Monday, December 10, 2007 11:31 PM | Feedback (50)
News
Welcome! This is the blog of a .NET software development enthusiast living in Silicon Valey, California, USA. The opinions posted here are my own and in no way represent the opinions of my employer or anybody else.