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 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

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:

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

Comments (8)

  1. Mikko Luukkonen says:

    Thank you. This instruction was really helpful. I was able to fix my machine following the instructions.

  2. Rohit says:

    OH MY GAWWDDD ! I had tried like every thing in this world to fix the issue.. was messing around with this for like 2 weeks ! Finally this thing came as a God GIFT ! Thanks a lot brother 🙂

  3. Ram says:

    Thanks a lot Chiranth. Been struggling with this issue for a week and this one worked like a charm 🙂

  4. Nikhila says:

    My load still point to same folder even after changing personal folder..

    I dont understand

  5. @Nikhila: Did you change those registry settings to point to the local?

    Kill all the iisexpress processes running from iisexpresstray. After changing this you can probably reset the settings of VS by running deven /resesettings and give it a try.

  6. Riyaz says:

    I follow the same instructions provided by you and its solved my issue.
    Thanks a lot Chiranth!!

  7. Riyaz says:

    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” folder

    It should work.. at least it worked for me.

  8. Khabba says:

    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

Skip to main content