Hosting shared folder from IIS 7 and VirtualBox

I have a Win7 guest running in VirtualBox. I’m working on a .NET project and got really sick of rebooting for Windows, so after some failed attempts to forward the ports for MSSQL and connect remotely, I have configured the guest to host my whole application while I develop and build in MonoDevelop.

I didn’t want to have to make a commit and push/pull every time I wanted to test, so I configured IIS 7 to use a shared folder from my host. However, conventional \\vboxsvr and VirtualBox shared folders do NOT work; IIS refuses to read the files, even after trying everything in the relevant Microsoft KB articles.

There is probably something wrong or incomplete in the VirtualBox implementation, because if you share the folder via Samba everything works swimmingly. I am using VirtualBox 3.2.8; if you are trying to use VBox’s shared folders to host a folder for IIS, stop now and set it up via Samba. This should solve any lingering difficulty unresolved by the Microsoft articles.

Once you have your share configured via Samba, just make sure that you configure IIS to “Connect as…” the user you’ve configured for Samba with smbpasswd and that you are using a UNC compatible path name (\\server\folder (in case of VirtualBox, this will usually be \\\folder)), not mapped drive letters like X: because mapped drive letters only exist for the users that mount them (i.e. your main user, not your IIS user).

You may get another security related error, which can be resolved by entering the .NET Framework Configuration Manager and enabling FullTrust for the correct Code Group (I just enabled it for LocalIntranet due to the inherently local nature of the VirtualBox setup on my development box).

This article may help if you are receiving the following errors:

  • “The requested page cannot be accessed because the related configuration data for the page is invalid”: 0x80070003, 0x80070005, etc.
  • Exception Details: System.Security.SecurityException: Security error. PublicKeyToken=b77a5c561934e089