9

I currently have an MVC6/ASP.Net 5 project. I "start without debugging" and the app loads in the browser. I can make changes to .cs files and recompile and they show in the app.

However, when I make any changes to razor files (*.cshtml) they don't show at all. I have to kill IIS express and re-launch in order to get the change to show. The rest of my team is working on the same code base/solution and it is working fine for them.

I have updated to VS SP1, and re-installed the tooling. No luck.

Please help!

Chris Kooken
  • 32,730
  • 15
  • 85
  • 123
  • Do you tried to clear the cache of the web browser? Sometimes old file could be loaded with wrong *datestamp* and it will be used instead of loading new version from the server. You can use Fiddler to verify which cache HTTP header get you if you loads the razor file from IIS. – Oleg Jan 07 '16 at 00:44
  • Yes. They are coming back as 200, not 302. I even try an incognito session. – Chris Kooken Jan 07 '16 at 01:13
  • A temporary rescue is to add a cache-buster to the browsed URL (?nocache=1, 2 etc) and at the same time introduce a Razor c# syntax error. Then, after reloading, remove the syntax error and the page will be reloaded... –  Nov 02 '16 at 05:02

4 Answers4

4

Most probably you have the .csproj MvcBuildViews property set to true. To check, unload the project (right-click it) and then edit it with the text editor.

The property gets rid of the "lag on first visit of view", but increases build times (and startup times) as well as introducing situations like this.

If you have it enabled, only enabling the property on Release (and not Debug) configurations might help:

Replace the <MvcBuildViews>true</MvcBuildViews> with the following:

<MvcBuildViews Condition="'$(Configuration)'=='Debug'">false</MvcBuildViews>
<MvcBuildViews Condition="'$(Configuration)'=='Release'">true</MvcBuildViews>

---------- EDIT ---------

Actually, sometimes this is not enough. Most probably (after the one above), you have the optimizeCompilations="true" attribute set on the <compilation> element inside <system.web> in your web.config.

If you don't want to remove that, you can periodically remove all the contents of this folder: %localappdata%\Temp\Temporary ASP.NET Files\vs (yes, you can enter that directly into the file explorer address bar)

Also, try the suggestion in my OP-comment:

A temporary rescue is to add a cache-buster to the browsed URL (?nocache=1, 2 etc) and at the same time introduce a Razor c# syntax error. Then, after reloading, remove the syntax error and the page will be reloaded...

  • Great suggestions, but what a pain. Does MS ever eat their own dogfood? Surely, they must know about this issue if they use their own product. – ATL_DEV Dec 01 '18 at 17:19
2

I had the same issue.

Closing Visual Studio and deleting .vs folder in the solution directory worked for me.

I think my IIS Express's configuration was corrupted. This may be why it worked for me.

Yves
  • 3,752
  • 4
  • 29
  • 43
2

It's a bug, and I found an answer to this that solves it here on StyackOverflow. Other Stack article here

netfed
  • 602
  • 8
  • 18
0

Try clearing out your IISExpress cache / application space: https://gyorgybalassy.wordpress.com/2013/12/02/cleaning-up-iis-express-configuration/

It's worked wonders for me before.

Monza
  • 745
  • 4
  • 12