Deploying our .NET 4.0 StackService service to IIS 6

Unfortunately the server I’m writing a ServiceStack service for is not only restricted to .NET 4.0 but also running IIS 6.0. I also need to deploy the service as a virtual directory off of the Default Web Site.

The first thing we want to do is publish/copy the files that make up our service to the IIS server.

Here’s the steps I took to get this working, obviously they may differ depending upon what access you have to the web server (and whether you deploy direct) etc.

  • From your ASP.NET/ServiceStack application, select the web service project and right mouse click.
  • Select Publish
  • Select Custom and set a profile name, mines “Files”, press OK
  • I’m going to copy the files across to the server myself, so for Publish Method, select File System and then enter a location to write your files to, click the next button
  • Leave the Configuration as Release
  • Press the Publish button

At this point the file location you selected will have the files required for the service.

Now if not already done as part of the publish steps, copy the files to the location you want to deploy them on your IIS 6.0 server. For example mine are in a folder named TestStack. Now we need to setup IIS to expose the service.

  • Open Internet Information Services (IIS) Manager or run %SystemRoot%\system32\inetsrv\iis.msc to open it
  • Expand the local computer node in the left hand tree view
  • Expand Web Sites
  • Right mouse click on the Default Web Site and select New | Virtual Directory
  • Press the Next button and enter an alias, i.e. TestStack in my case
  • Press Next and browse from IIS or enter the folder location of your service (you want the root, not the bin folder) in your browser and press next
  • Ensure Read and Run scripts (such as ASP) are checked and press Next
  • Click Finish

On the properties, Documents tab, uncheck the Enable default content page

Not sure the above is a requirement to get things working, but just happened to be something I set

On the Virtual Directory tab ensure the Execute Permissions is set to Scripts and Executables

On the ASP.NET page, ensure the ASP.NET version is 4.0.xxx

Now the virtual folder you be setup. If you’ve not got your service selected in the IIS Default Web Sites node, then select it and right mouse click, then select browse to see if all is working, or open your preferred browser and enter

http://<hostname>/StackService/metadata

If you are getting a 404 The page cannot be found error, then this might help

See Can’t get ServiceStack to work in IIS6 with HTTPS

The exact steps I took are listed below

  • Select the virtual directory in IIS, right mouse click and load the properties
  • From the Virtual Directory tab, press the Configuration button
  • Press Insert
  • From file explorer locate aspnet_isapi.dll for .NET 4.0, for example mine is located in %windir%\Microsoft.NET\Framework\v4.0.30319
  • Once located enter %windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll (replacing %windir% with you actual location) in the Executable textbox
  • Uncheck the Verify that file exists checkbox, then press OK
  • Press OK again and again until the properties dialog is closed

Now if you refresh or reload the URL for the virtual folder or again select Browse from IIS, the meta data from ServiceStack should be displayed.

Whilst this may be a fairly specific case, i.e. deployed to .NET 4.0 on IIS 6.0, I thought it might still be a useful post anyway.