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
C:\Users\chiranth\Source\Workspaces\xxxxxxx\xxx\xxxxxxx\xxxl.WebUI.csproj : error : Creation of the virtual directory http://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
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
But what if you don’t find the key being set at all , 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
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
Old value: \\chiranth8r2\c$\Users\chiranth\Documents
New value: C:\Users\chiranth\Documents
Hope this helps