Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kestrel / IIS Express requires restart before edited .cshtml view changes are shown in browser

I'm in the process of setting up my first ASP.NET vNext web application project.

I've got as far as getting the default project to build and run fine in both Windows and OSX. I've tested with kestrel on the mac, and in Windows IIS Express along with kestrel.

The problem I have encountered is that in Windows, editing a cshtml View file while the web server is running isn't reflected when I next refresh the browser.

  • In OSX, I can run 'dnx web' and navigate to localhost:5000 and browse the site. I can then edit the .cshtml View files, switch back to the browser, hit refresh, and I can see all the changes. This is what I expect to happen and happened in previous versions.*

  • In Windows, I can either run dnx web or IIS Express on the same site as I was using on OSX, navigate to localhost:5000 (or for IIS Express its own port number) and browse the site. I then switch to edit the cshtml View files, but when I switch back to the browser to reset, the changes aren't shown. It's not until I restart kestrel or IIS express that the changes are shown.

Curiously, however, I can edit a .cs Controller file and the site then recompiles by itself and I don't need to re-start it - in Windows at least. (In OSX, editing a controller file doesn't cause an auto-recompile, but that's an aside, I believe dnx-watch will fix that).

Is there something that I've missed in the project.json, or another setup file, which is causing the issue in Windows?

I have tried:

  • creating a second completely clean web application project
  • reinstalling ASP.NET
  • desperately, lastly, creating a clean install of Windows 10 with Visual Studio 2015 Community Edition, to no avail

What's the way to get Kestrel or IIS Express in Windows to serve the updated cshtml View file after it's been edited, without restarting the server?

*side note, ASP.NET MVC in OSX is awesome!

like image 700
Anthony Avatar asked Oct 19 '22 21:10

Anthony


2 Answers

Following on from @SRQ Coder's response, in particular the reassurance that it's supposed to work as I hoped, I found the reason but as yet no decent solution.

My project directory is located on a network share and I load the projects directly from there (I run Parallels Desktop on a mac). This works great with ASP.NET 4.x / MVC 5 (and earlier). However it looks like ASP.NET 5 doesn't support this setup.

The moment I copied the project folder to the local C: drive it all worked fine

When opening the project from a \\network-share, the project loads and I can run/debug the website, but CSHTML edits aren't shown in browser until IIS Express/Kestrel is restarted

Opening the project from a X:\ mapped network drive doesn't make any difference

like image 162
Anthony Avatar answered Nov 02 '22 07:11

Anthony


I'm not able to recreate your problem on my machine: VS2015; Win10 etc. in either the IIS mode or Web: localhost/5000 mode and on multiple browsers.

I can edit both 'shared' cshtml files like '_Layout' and also the default 'home/index cshtml file with no problem.

Since you've re-installed so much of your system, I'm wondering if you have not re-installed web-essentials and enabled 'browser link'.

I feel your pain...

like image 40
SRQ Coder Avatar answered Nov 02 '22 09:11

SRQ Coder