51

I'm running Windows Server 2008 R2 (x64) with IISExpress8 and when navigating to

c:\Program Files (x86)\IIS Express>iisexpress.exe

it says:

Filename: redirection.config

Error: Cannot read configuration file

Any ideas where to start? I can't find anything...

Liam
  • 27,717
  • 28
  • 128
  • 190
user1275154
  • 1,120
  • 1
  • 12
  • 24
  • 1
    I found this question while traying to resolve an issue with Windows 10 and Visual Studio 2015. My fix was: my user could not write to my personal folder (I'm in Administrators group and I'm the folder owner), so I went to security configurations and give myself full access. Restarted VS 2015 and voi-la =) – JCKödel Jul 17 '15 at 21:27

29 Answers29

66

I had a similar issue to @Myles J but renaming %userprofile%\Documents\IISExpress\config\applicationhost.config didn't work. What I had to do was the following:

  1. Close Visual Studio.
  2. Rename the %userprofile%\Documents\IISExpress\config directory.
  3. Start Visual Studio again. The %userprofile%\Documents\IISExpress\config directory will be recreated with the default config files.
  4. Copy the original applicationhost.config file over the autogenerated one.

Before anyone asks: the permissions on the folders were identical, the read-only flag was not set on the folder or its files, and I didn't modify applicationhost.config in any way.

Ian Kemp
  • 28,293
  • 19
  • 112
  • 138
  • 1
    For future devs -- this didn't work for me until after I had uninstalled/reinstalled IIS Express. I renamed the folder, launched VS, didn't work. Reinstalled IIS Express, launched VS, got the error. Stopped VS, renamed the folder, restarted. No error. (VS2013, IISExpress 8.0) – Daniel Szabo Dec 15 '14 at 16:52
  • 7
    I had my documents stored in OneDrive, and the /IISExpress folder was marked "online only". So the shadow file was there, but Visual Studio couldn't read it. Right Click the IISExpress Folder, and select "Make Available Offline" or as other mention (i didn't try this) maybe delete the folder. Then everything worked! – ScottCate Jan 27 '15 at 22:00
  • 2
    Exactly the same situation as @ScottCate Made the \Documents\IISExpress folder available offline. Renamed the config folder to config.backup and restarted Visual Studio (2015 RC).. that fixed it. – Shailen Sukul Jun 19 '15 at 11:41
  • Similar to @ScottCate and Shailen_Sukul, - right-click and selected **Make Available Offline** - didn't even bother to make a backup copy of config directory - but, maybe a good idea - restarted Visual Studio – bkwdesign Sep 22 '15 at 21:42
  • I dont have this folder %userprofile%\Documents\IISExpress\ – Paul Ledger Feb 16 '17 at 13:43
  • In my case, I tried to reload the project couple times, didn't work. Tried to close the visual studio and re-opened, didn't work. Checked on internet. Came to this page. Just thought to give another go by clicking on 'Reload project'. And it worked. Just like that ! – Sukhi Jul 20 '17 at 16:18
  • This works for me every time when I accidentally replace my local applicationhost.config with the one that has somehow got checked into source control – Dan Cook Jul 25 '17 at 08:43
  • Another OneDrive victime is here. I authenticated to me onedrive account and then the problem resolved. Finally I removed the OneDrive for peace. – Paradox Apr 05 '22 at 11:15
60

After installing IIS Express, copy all files from

C:\Program Files\IIS Express\config\templates\PersonalWebServer

to

%userprofile%\Documents\IISExpress\config

Zameer Ansari
  • 28,977
  • 24
  • 140
  • 219
user3877075
  • 601
  • 5
  • 2
  • 2
    This did it for me, +1. – Wim Aug 13 '14 at 13:54
  • 1
    It's stuff like this that makes working with VS and dotnet = working hard. Not working smart. Thank you. – Kentonbmax Jul 19 '19 at 12:09
  • I found that files inside %userprofile%\Documents\IISExpress\config was missing for me, suddenly i day i started facing this issue, may be some corporate cleanup did clear files for me. I did as mentioned an error is gone, Thanks alot for fix – Pankaj Singh Jun 14 '20 at 09:09
32

Right click on your project file and Edit the project file and remove the URL from IISUrl and reload your project then it will work

Deva
  • 329
  • 3
  • 2
  • 8
    Why aren't there more upvotes for this? This is the easiest (and also the correct) solution offered. +1. – darkfreq Nov 12 '14 at 23:12
  • I also had to clear out the IISAppRootUrl item from the project, but a nice simple solution – Roadkillnz Jan 27 '15 at 21:02
  • Messing with the IIS Express config directory and files did not work. This solution (editing the project file) worked perfectly. Thank you Deva. – mr_plum Feb 27 '15 at 14:30
  • Thank you so much for this answer. I deleted the value (just leaving ) and my build succeeded. I agree that more people should have upvoted this. – Robert Bernstein Nov 05 '15 at 15:31
  • Didn't work for me. I removed the value under IISUrl, and tried to reload. Didn't work. The removed the IISUrl tag, tried to reload.. didn't work. I removed the DevelopmentServerPort tag, tried to reload.. didn't work. Tried removing the parent tags, and finally removed the project extensions tag. NONE of them worked! Terrible.. It randomly worked if I disabled Resharper on VS startup. I had to enable Resharper (to work with unit tests), and I needed to restart VS again for Resharper to work. Then I get the SAME PROBLEM!! – Ren Mar 27 '18 at 10:42
12

I have just resolved this. It is a strange solution but it worked for me. Here are the steps I took:

Navigate to the folder containing the local IISExpress config files (normally My Documents>IISExpress>config on Windows7).

Find the applicationhost.config file. Rename it to something different e.g. applicationhost2.config.

Navigate to your web project in Visual Studio (I was using VS 2012). Right click on the web project and select Use IISExpress. Run the project. It should fail due to the renaming of the config file.

Change the name of the configuration file back to application.config. Ensure "Use Local IIS Web Server" is selected in the web project settings. Run the solution.

This worked for me.

Myles J
  • 2,839
  • 3
  • 25
  • 41
  • @Myles J - in my case, after renaming applicationhost.config, VS2015 just recreated it when I loaded the solution. However, although I can now load my solution and projects, it will NOT run. it builds fine, but I get the `System.BadImageFormatException: Could not load file or assembly 'myApp.DAL' or one of its dependencies.` – bob.mazzo Jan 29 '16 at 18:34
  • This worked for me also. Quite strangely. So the project .vs/config/applicationhost.config is not overriding the one inside Documents/IISExpress !! Its interesting to see this conversation being going through many years!! :) – SydMK Apr 30 '19 at 01:57
8

If you do:

C:\Users\”username*****”\Documents\IISExpress\config

You find these file

applicationhost.config
aspnet.config
redirection.config

Delete above 3 file and then open the project.then the problem is solved. I tried, its working fine.

durron597
  • 31,968
  • 17
  • 99
  • 158
Ramu Jannu
  • 81
  • 1
  • 1
7

Visual Studio will only report the filename it looks for, not the full path. The problem for many users is that the IISExpress with the redirection.config can exist in multiple paths, including a OneDrive path which may not be synced.

To figure out exactly what file Visual Studio attempts to open, use the Microsoft (SysInternals) tool ProcMon. It lists all files and resources Windows tries to access. Add a filter for "Path contains redirection.config" and reproduce the problem in Visual Studio. Now you will see the actual path it tries to use.

In my case, I have multiple IISExpress folders. One that was synced to OneDrive and another one that was local. Visual Studio tried to access the OneDrive folder which was not synced to the local disk, and thus it failed.

Forcing IISExpress folder to store files locally resolved the problem

Dan Gøran Lunde
  • 5,148
  • 3
  • 26
  • 24
  • This is exactly my problem. I just start the onedrive service/app and then I right clicked the files and selected the "Keep always in this device" option. I use the Brazilian Portuguese version, so the exact command I dont know, but is something like "Keep always". Original: "Manter sempre neste dispositivo" (pt-BR). Worked like a charm. Thanks @https://stackoverflow.com/users/134850/dan-g%c3%b8ran-lunde – ASPaiva Feb 05 '21 at 14:40
  • I had the same issue, switched computers and it was picking up the OneDrive version of the IISExpress templates, deleting the folder fixed the issue. – Ryan Rife Aug 03 '21 at 17:46
  • This worked for me. Onedrive was the culprit. – Sha Apr 17 '22 at 22:15
6

I have the exact same issue with Visual Studio 2013 on Windows 8.1 I map My Documents folder to SkyDrive, so the IISExpress folder was marked as "Online-only". Once I marked it as "Available offline" everything worked.

Matt
  • 6,264
  • 10
  • 54
  • 82
  • 4 hours later, and this dawned on me.. Not the first time online-only files have reared their ugly heads with unexpected behavior. Shouldn't this kind of stuff 'just work', no different than if I'd tried to open the file directly from explorer? – JoeBrockhaus Jun 11 '14 at 05:07
4

In some situations simply renaming/deleting the applicationhost.config file isn't enough since VS won't always recreate it for you. I believe the following will fix it under all circumstances:

Close Visual Studio.

Make sure there are no IIS Express processes running, then delete C:\Users\XXXX\Documents\IISExpress\config\applicationhost.config (where XXXX is your Windows username).

On command line, execute c:\Program Files\IIS Express\iisexpress.exe. This will recreate the necessary configs. Press 'Q' straight away to end the process.

Open Visual Studio again and Start/Debug your web project. Everything should now be working.

David Fidge
  • 451
  • 5
  • 6
3

Backup files at local IISExpress folder. It can be found at: C:\Users\”username*****”\Documents\IISExpress\config
Go to the location:
C:\Program Files\IIS Express\config\templates\PersonalWebServer
Copy the required files from this directory to the local IISExpress folder.
It worked for me after I copied over the files:
applicationhost.config
aspnet.config
redirection.config

user_s
  • 81
  • 1
  • 2
  • Only thing I had to do, was turn off UseIIS in the project file, and copy the redirection.config to my username's IISExpress config. – Maslow Mar 27 '15 at 17:35
3

In my case the 'My documents' folder for my work laptop was mapped to a network share. So when the work network was not available I was not able to open my solution.

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

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

For eg:

Old value: \networkdrive\c$\Users\profile\Documents

New value: C:\Users\profile\Documents

See: https://blogs.msdn.microsoft.com/chiranth/2015/04/01/error-while-runningstarting-a-website-under-iisexpress-in-visual-studio/

Khabba
  • 41
  • 2
2

The issue is that the files in C:\Users\"Your Username"\Documents\IISExpress\config are encrypted. Open this folder, Select all the files, Right click and select properties, Click advanced, deselect "Encrypt contents to secure data, Click okay, click apply.

That will fix it.

jshaw
  • 21
  • 4
1

Using Visual Studio 2013

I had to stop visual studio rename the whole config directory, Documents > IISExpress> Config then start a new web project, which fails but it recreates the config directory, then I rebooted and launched visual studio and everything worked!

I noticed this problem after copying a project between 2 computers, perhaps it was caused by a duplicate IISExpress port or something trivial.

JustEngland
  • 1,371
  • 13
  • 30
  • Yeah, rebooting fixed it for me :-( Checking with ProcMon beforehand showed every access to `*.config` succeeded. – Mark Hurd Jul 09 '15 at 04:16
1

Using VS2013 / Windows 7

Close solution. Open Windows Explorer and right-click on "My Documents\IISExpress\config" directory and select "Decrypt". Be sure "Apply changes to this folder, subfolders and files" is selected. Reopen VS solution.

1

In my case it happened when IISExpress was still active from a previous VS session and new instance of VS was run.

The solution was to stop (or kill) IIS Express instance.

andrew.fox
  • 7,435
  • 5
  • 52
  • 75
  • 1
    This worked for me, too. Tried quite a few of the above options to no avail. Stopped IIS Express then reloaded project. Project did not have a project file, was just a web site (so just a folder) referenced in a solution file. – fritterfatboy Aug 14 '15 at 16:19
1

Fix was really simple for me >> Restart Visual Studio

My setup:

  • Visual Studio 2015

  • Web projects use local IIS 8.5

  • I occasionally experience what I believe to be a VS bug where it converts some projects to use IISExpress (this is fixed by deleting the folder created in /This PC/Documents). This might be related.

GraehamF
  • 1,971
  • 24
  • 24
1

You don't need to close Visual Studio or rename anything.

  1. Open properties for %userprofile%\Documents
  2. Select Security > Advanced, change owner to yourself (again if you are already owner).
  3. Select "Replace owner on subcontainers and objects" and "Replace all child object permission entires with inherited permission entires from this object".
  4. Ok.
amuliar
  • 1,318
  • 15
  • 26
1

For me, It's a simple lack of permission either give everyone permission to "%userprofile%\Documents\IISExpress\config" this folder or Open VS in Admin mode

GSKKC
  • 45
  • 6
1

for me was removing the file Documents\IISExpress\config\applicationhost.config

Closing visual studio > Open > Debug

Thanks for the previous answer help go straight to the issue

0

After trying to solve an issue with a quick fix of changing IIS express inside visual studio from integrated to classic pipeline , I ended up not being able to use IIS express at all. I tried all techniques above...

I could not rename , copy the file. Uninstall of IIS express and re-install did not work.

I FINALLY downloaded the latest version of WebMatrix and installed IIS express 8, that did not work, but at least then i was able to finally delete the old directory and then I recreated itself.....

NOT FUN AT ALL.

Tom Stickel
  • 19,633
  • 6
  • 111
  • 113
0

I resolved this (with vs2013 and windows 7) by going to Documents > IISExpress> Config and renaming the application.config. After that, I restarted visual studio and opened my project and it worked.

nixkuroi
  • 2,259
  • 1
  • 19
  • 25
0

I ran into this issue while trying to open another developer's solution after installing VS2013 (Update 3 RC). After following the advice here and deleting/renaming/etc. the config folder, VS re-created the files in the wrong location. It created nested config folders:

C:\Users[user]\Documents\IISExpress\config\config

I moved everything from ...\config\config into ...\config, and it worked as expected.

Brandon Gano
  • 6,430
  • 1
  • 25
  • 25
0

I found that deleting one of the sites from the applicationhost.config file resolve this problem for me.

I used the following command from the %ProgramFiles(x86)%\IISExpress directory:

appcmd list site

then

appcmd delete site rogueSiteName

Especially there was a site name with a bracketed number suffix (e.g. "MySite(1)") that I deleted. I'm not sure yet if VS2013 just had an issue with the brackets or that two sites pointed to the same directory. Either way deleting it made VS happy again.

Background

I had been struggling with this issue for a couple of days and nothing seemed to help - not even the instructions given in the top answers here.

I had also tried moving the config folder as mentioned in http://www.iis.net/learn/extensions/introduction-to-iis-express/iis-80-express-readme. But although VS2013 recreated the directory structure and files in the new location the errors continued and running appcmd showed that it was still pointing at the old location by default.

Credits

Credit for where I found the commands to use goes to http://gyorgybalassy.wordpress.com/2013/12/02/cleaning-up-iis-express-configuration/

WooWaaBob
  • 3,397
  • 3
  • 23
  • 23
0

For ASP.Net Core just access your Properties section, then make a modification and save it.

Example: I modified the SSL port Core Example

You will get a notification that your launchsettings.json was modified. Accept that and you're good to go.

Razvan Dumitru
  • 11,815
  • 5
  • 34
  • 54
0

If it is ASP.NET Core project

Just try to change iis port in file launchSettings.json by path iisSettings:iisExpress:applicationUrl

skorenb
  • 629
  • 1
  • 9
  • 16
0

It's 2020, I am reporting the same problem in Visual Studio 2019.

Cause: Multiple VS instances open with different web app (Blazor in my instance).

Solution: Close all VS instances and re-open the solution that you want to run.

Johnny Wu
  • 1,297
  • 15
  • 31
0

On IIS 10 Express. Make sure that Visual Studio (VS) is turned off.

I first found out that %userprofile%\Documents\IISExpress\config\ was not working.

I first thought IIS Express had clashed with IIS from the windows OS.

I uninstalled it, yet no changes, then I uninstalled IIS 10 Express that was installed with VS 2019 through the control panel.

Then I went ahead to discover that this file is saved at the C:\Users\username\OneDrive\Documents\IISExpress, associated with one drive storage, so I advise you copy %userprofile%\Documents\IISExpress\config\ and paste in your windows explorer navigation to find directory.

go to one directory higher, and/or rename the config folder. Restart your VS and run the project again.

Rikudou En Sof
  • 526
  • 1
  • 4
  • 21
0

Mine was caused by OneDrive. Apparently my documents folder is being synced to it. What I did is changed the location of the documents folder through regedit and navigated to this path:

HKEY_CURRENT_USER > Software > Microsoft > Windows > CurrentVersion > Explorer > User Shell Folders

and then changed the value of Personal from: C:\Users\my username\OneDrive\Documents to C:\Users\my username\Documents

After that I restart my computer and I was able to create a VS project.

Andrew Casal
  • 91
  • 1
  • 6
0

I have the same issue, First time, i think Visual Studio not permission access to %userprofile%\Documents\IISExpress\config so i run Visual Studio with Administrator, but it not working. I try all answer above but still the error!

Finally, i look internet, i see my onedrive is stopping, i enable and sync data. Restart computer and worked.

HOÀNG LONG
  • 391
  • 2
  • 12
0

Just uninstalled OneDrive from your comp

Eyal
  • 4,653
  • 9
  • 40
  • 56