Share via


Error while running/starting a Website under IISExpress in Visual Studio

Recently I have come across several issues and have seen variosu queries in connect.microsoft.com and stakcoverflow where developers are unable to start or load their website in IISExpress all of a sudden and this remain unanswered.

The issue may surface and we may receive different errors. Below are some of such errors

1.

C:\Users\chiranth\Source\Workspaces\xxxxxxx\xxx\xxxxxxx\xxxl.WebUI.csproj : error : Creation of the virtual directory https://localhost:52124/ failed with the error: Filename: \\?\UNC\xxxxx-host\Shared Folders\Documents\IISExpress\config\applicationHost.config

Error: Cannot write configuration file due to insufficient permissions

2.

Unable to launch IISexpress Webserver Start url specified is not valid. HTTP//localhost:60081" on running asp.net web application

In one of the cases it complains about permissions and in the other it complains about the start url.

in both the cases I observed that the configuration file(applicationhost.config) was being read from a network share.

On further investigation I found out that we had the My Documents folder point to a shared drive or network share.

in 2 out of 3 instances I have seen this issue appear when the network share being pointed to is a MAC share.

Also when we have this in a network share I also observered that in one of the machine the applicationhost.config was going into corrupt state every time as there were “NUL NUL” being inserted into the applicationhost.config file.

I suspect the issue either because how the data is written over network for different operating systems. And in other scenarios it was because of the network share going down.

So the million dollar question is “How to change the custom user home directory for IISExpress?”.

If you research over internet on how to change the custom user home directory for IISExpress you will see in various references that you can change it by following the below steps.

Changing the User Home Directory
  • IIS 8.0 Express supports changing the user's home directory, which is mapped to the %IIS_USER_HOME% variable in configuration. By default this path is located at %UserProfile%\Documents\IISExpress, but users can change this by setting a CustomUserHome registry property in HKCU\Software\Microsoft\IISExpress, or by specifying the "/userhome" parameter when launching iisexpress.exe

But what if you don’t find the key being set at all Smile, which was the same case which happened with me.

So after lot of research I identified the below registries where the location of My documents will be changed and we need to revert these back.

We need to change the default path of the My Documents directory from network share to the local or you can try pointing to a different network share if you don’t want to choose the local option. There are options in the UI to achieve this but it didn’t work for me.

So fail proof method is to modify the below registries which will be pointing to the network share. Take a backup of the registry keys before modifying it Smile

I. Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal

II.  Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal

These will have the value of my docs in network share. Change this to local

For eg:

Old value: \\chiranth8r2\c$\Users\chiranth\Documents

New value: C:\Users\chiranth\Documents

 

Hope this helps Smile

 

References:

https://www.iis.net/learn/extensions/introduction-to-iis-express/iis-80-express-readme

Technorati Tags: IISExpress,Visual Studio 2012,Unable to start IISExpress,Cannot write configuration file due to insufficient permissions

Comments

  • Anonymous
    April 19, 2015
    Thank you. This instruction was really helpful. I was able to fix my machine following the instructions.

  • Anonymous
    September 07, 2015
    The comment has been removed

  • Anonymous
    November 17, 2015
    Thanks a lot Chiranth. Been struggling with this issue for a week and this one worked like a charm :)

  • Anonymous
    December 21, 2015
    My load still point to same folder even after changing personal folder.. I dont understand

  • Anonymous
    December 22, 2015
    The comment has been removed

  • Anonymous
    April 21, 2016
    I follow the same instructions provided by you and its solved my issue. Thanks a lot Chiranth!!

  • Anonymous
    April 21, 2016
    I found 1 more solution for this problem:GO to \chiranth8r2\c$\Users<>\Documents folder>> Grant full access to logged-in user to "IISExpress" and "Visual Studio 2015" folderIt should work.. at least it worked for me.

  • Anonymous
    August 29, 2016
    Yes finally!I've added this solution to a Stack Overflow thread. Hope somebody sees it.http://stackoverflow.com/questions/15897726/iisexpress-8-cannot-read-configuration-file-redirection-config/39205168#39205168

  • Anonymous
    July 08, 2017
    Thanks a lot!