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?
In my case I moved the folder to another location, so I had to edit the applicationhost.config file and changed the virtualdirectory entry to the new location. Removing encryption and setting read only off did not help. I imagine if I had just copied it instead of moving it, it would have happily continued working.
I had the same issue before, running VisualStudio as Administrator (Run as Administrtor) resolved the issue.
I received the same error but in a different context. Opening a project (.csproj file) provided by another developer returned this error and failed to do anything:
I removed both Encryption and the R/O attribute from the directory containing the project files and applied to all subfolders and files. Visual Studio can now read the project.
C:\Users\xxxxxx\Documents\IISExpress\config\applicationHost.config
Uncheck the read-only attribute from the file. It worked for me.
For anyone googling this; this might be the same problem as this: http://connect.microsoft.com/VisualStudio/feedback/details/878812/use-iis-express-is-broken-in-vs-2012-on-windows-8-1
You can check it by downloading Prcocess Monitor and run it with a filter for "Path" contains "\Documents\IISExpress\config" and then try to change the project to use IIS Express. If there is a CreateFile entry with the result 0xC0190052 as one of the last entries then this is the same issue.
I also had the problem and tried to fix it with setting the registry key in HKCU\Software\Microsoft which didn't work.
The error I made, was using HKCU because, since I do not have permissions to edit the registry under by normal account (which I use to run visual studio), I was using an administrative account. Then of course, HKCU was for that account.
So I just used HKEY_USERS\"my normal user's SID" instead and, when starting iisexpress.exe manually, it created its files at the location indicated. What still didn't work was using iisexpress from visual studio. It still seemed that VS didn't use the registry setting at all.
Finally I resorted in setting a non UNC path for Shell Folders\Personal and User Shell Folders\Personal in HKU\"my normal user's SID"\Software\Microsoft\Windows\CurrentVersion\Explorer\ which did the trick.