IIS Express 8 - Cannot write configuration file

2019-02-07 17:03发布

I am trying to use IIS Express 8 for a MVC site in VS2012. I am getting the following error whenever I attempt to create the site:

Filename: \?\C:\Users\xxxxxx\Documents\IISExpress\config\applicationHost.config
Error: Cannot write configuration file

Is there some way to force IIS Express to use a different location for the config & logs folders? I understand I can point to a different location when I am running iisexpress.exe from the command line, but I have no control over this when using Visual Studio.

Alternatively, has anyone got any suggestions why the error is happening? (Side note: My laptop is in a corporate environment which has some stupid encryption on the "Documents" folder, however I haven't had any problems with other software that saves to this location. I also have given the "Everyone" group full access to the folder.)

EDIT - After following the instructions at http://learn.iis.net/page.aspx/1286/iis-80-express-readme/ I still can't seem to get this working. I've tried the following:

  • Added HKCU\Software\Microsoft\IISExpress\CustomUserHome registry key pointing to my alternate directory
  • Added HKCU\Software\Microsoft\IISExpress\8.0\CustomUserHome registry key pointing to my alternate directory
  • Added HKLM\Software\Microsoft\IISExpress\CustomUserHome registry key pointing to my alternate directory
  • Added HKLM\Software\Microsoft\IISExpress\8.0\CustomUserHome registry key pointing to my alternate directory
  • Setting the %IIS_USER_HOME% environment variable pointing to my alternate directory.

Any other suggestions?

12条回答
【Aperson】
2楼-- · 2019-02-07 17:39

After struggling with this, and verifying encryption and read-only attributes, and having them not work, my solution ended up being:

  • Navigate to the folder containing the IISExpress folder (in my case, it was in my OneDrive, not Documents folder)
  • Right click on IISExpress folder > Security tab > Advanced button
  • Change Owner to yourself, even if it already is
  • Check the "Replace owner on subcontainers and objects" box
    • This may not appear until you've completed the Change owner dialog
  • Open the IISExpress folder
  • Right click on config folder > Security tab > Advanced button
  • Add a user > Add principal
  • Change location to local machine (and not a domain)
  • Enter the name NETWORK SERVICE and "Check Names"
  • Press OK to get back to the Advance Security dialog
  • Make sure to check "Replace all child object permission entries with inheritable permission entries from this object"

Worked in Windows 10 with IISExpress 10, for both VS 2013 and VS 2017.

查看更多
够拽才男人
3楼-- · 2019-02-07 17:43

I'm also in a corporate environment with Encryption on the users folder, and removing encryption and removing the read only flags on everything in the IISExpress folder worked for me.

查看更多
可以哭但决不认输i
4楼-- · 2019-02-07 17:44

I'm using Visual Studio 2017 on Windows 10 and to fix this problem I had to disable the OneDrive setting "Save space and download files as you use them". After changing the setting my computer crashed but after rebooting I was then able to change SSL Enabled and everything worked.

查看更多
该账号已被封号
5楼-- · 2019-02-07 17:46

@Brad

I had your same problem just now. Removing the encryption on the IISExpress folder and the "Read Only" attribute solved it. In my company Documents is also encrypted, but I don't think removing that encryption from IISExpress would be a problem of any sort.

Hope this helps.

查看更多
劳资没心,怎么记你
6楼-- · 2019-02-07 17:46

Adding the registry entry seemed to work, however, using environment variables in the registry entry did not. In my environment only our documents directory is redirected, so I simply wanted to move the IIS Express config directory up one level to the %USERPROFILE% directory. However, that did not work. IIS Express read the environment variable literally and of course failed to run.

查看更多
太酷不给撩
7楼-- · 2019-02-07 17:48

I had a very similar error message caused by a completely different problem.

The Error:

C:\VS\TFS_Projects\SomeSolution\SomeProject\SomeProject.csproj : error : Creation of the virtual directory http://localhost:55063/ failed with the error: Filename: \\?\C:\VS\TFS_Projects\SomeSolution.vs\config\applicationhost.config Error: Cannot write configuration file due to insufficient permissions

More Details: I couldn't even open the project, as opening it would fail.

I could get prior changesets, and they would actually open fine, but if I got latest the projects couldn't be opened.

Solution: In my case, it turned out that when we changed TFS servers, someone had added the ".vs" folder to source control along with everything else. Under which, one developer had his applicationhost.config set up to run sites on a D:\ drive, while I had no such D:\ drive (well, it was a DVD drive.) I was able to get this working by finding a prior changeset with the un-altered applicationhost.config and replacing my local file. (I could have attempted to actually delete the folder, but I didn't go that route.)

Afterwards, we removed the ".vs" folder from source control.

(I put this solution here because it's where google landed me, so other people having this error message might find the above solutions don't fix it for them, and thus they might be having this problem.)

查看更多
登录 后发表回答