BrowserReloadOnSave icon indicating copy to clipboard operation
BrowserReloadOnSave copied to clipboard

Not refreshing on reload of cshtml file

Open Larswa opened this issue 10 years ago • 25 comments

Hej Mads,

Installed product versions

  • Visual Studio: [example 2015 Enterprise Update 3]
  • Web Essentials 3.0.235

Description

When running an ASP.NET Core application (1.1 running on top of 1.1 Core) Browserlink is enabled and working across browsers (IE, Chrome, Edge, Firefox). Saving a JS or CSS file triggers an automatic reload of all browsers. BUT on saving changes to a razor view cshtml file does not trigger a reload.

Steps to recreate

  1. Create new 1.1 aspnet core app
  2. ctrl-f5 to start app in browser.
  3. Check in the browserlink windows that a browserlink is active between vs and the browser
  4. save a change to a cshtml file - new HTML segment or change the CLASS property ...
  5. See how the browser does not automatically reload.
  6. Check that a change to a Javascript or CSS file does reload the browser.

Current behavior

I was expecting the browser to reload on any change to any of the files listed in the file filter in [Options\Web\Browser reload on save]

Expected behavior

Reload .... 🎱

Larswa avatar Dec 04 '16 21:12 Larswa

I am experiencing the same issue.

If I press CTRL-ALT-ENTER the page refreshes correctly on save

css which wasn't working previously is now working correctly

dotnetshadow avatar Dec 08 '16 05:12 dotnetshadow

Thanks dotnetshadow. Just noticed your comment on the issue now. And thanks for the heads up on css. Will recheck that step.

Larswa avatar Dec 08 '16 21:12 Larswa

Yes I confirm that the refresh is working on updates to CSS, but javascript changes (even inline) or changes to the HTML does not trigger an update.

Larswa avatar Dec 08 '16 21:12 Larswa

I cannot reproduce the issue with version 1.0.20. The browsers reload just fine when saving a .cshtml file

madskristensen avatar Dec 14 '16 20:12 madskristensen

Okay - I have some more details that might explain the behaviour.

I am running a .net core 1.1 webapp, and I run it with [CTRL-F5] From earlier I have a an older "publish" folder beneath the "bin/netcoreapp1.1" folder.

If I update a css or javascript file through visual studio in the project folder, the sites are refreshed But I have to refresh a .cshtml view page in the "publish/Views" folder for the site to refresh on a saved view. It is still the one in the project folder that is reloaded (Not the one in the published folder), but it seems that the file event for views are (in my case) only triggered on cshtml files in the publish folder.

Does that make sense Mads?

Larswa avatar Dec 14 '16 22:12 Larswa

Also ... I am forcing a redirect to HTTPS and I am running it locally from VS in IIS Express (reverse proxy to kestrel).

Larswa avatar Dec 14 '16 22:12 Larswa

Just to add my extra information: I am also running .net core 1.1.0 web application

dotnetshadow avatar Dec 15 '16 03:12 dotnetshadow

I use plain ASP.NET MVC 5 on .NET Framework 4.5 and experience the same bug: changing in JS file makes the page to reload but changes in cshtml do nothing.

lromanov avatar Dec 20 '16 19:12 lromanov

It isn't working for me either. I am using asp.net core 1.1 and VS 2017.

mattfraley1 avatar Mar 08 '17 19:03 mattfraley1

I can confirm on Visual Studio 2017 asp.net core 1.1 that save on reload is still not working. I couldn't even get the css changing to work, I edited site.css but nothing happened until I click the refresh icon in vs.net

CSHTML - NOT WORKING CSS - NOT WORKING JS - WORKING

It's quite clear that this is not working for some people, we might have to start providing more information about our machines / environments

I thought the save command would just hook into the refresh button icon but obviously more is involved?

I did notice an error in chrome: [23:22:27 GMT+1100 (AUS Eastern Daylight Time)] Browser Link: Failed to invoke return value callback: TypeError: Cannot read property 'files' of null Line: browserlink:54

@madskristensen I'm happy to try and setup a remote desktop session with you to try and debug this, because I think you commented last time that you aren't able to reproduce the issue?

dotnetshadow avatar Mar 09 '17 00:03 dotnetshadow

I can also confirm what @dotnetshadow is seeing. VS 2017 RTM, asp.net core 1.1.1, .NET Core 1.1.1

I am getting the same javascript console error in FireFox. 20:10:57.780 [20:10:57 GMT-0500 (Central Standard Time)] Browser Link: Failed to invoke return value callback: TypeError: t is null1browserLink:64:566

It appears to be in the minified SignalR library that is bundled into the browserLink library.

I can zip up a very simple solution that reproduces the issue if that would help.

Update: I believe this is an issue with the native Browser Link client side script. I disabledBrowser Sync and BrowserReloadOnSave. The client side javascript error is still occurring, and the out of the box CSS Auto-Sync does not work.

gravidThoughts avatar Mar 13 '17 01:03 gravidThoughts

I can confirm that this issue is real. I couldn't get the Auto Reload feature working on Visual Studio 2015, 2017 (ASP.net Project)

The funny thing is that if I use some other editors such as Notepad++, the feature works as intended. Any idea why?

P/S: Given the past support of this extension, I don't think we can expect a fix from them, does anyone know an alternative extension?

romeoDo avatar Apr 23 '17 13:04 romeoDo

That is a cleaver trick. I just tried the same thing with vs code and it worked. A temporary work around I guess. Maybe there is a another process hijacking the save event in VS? I have several add ins doing things like format on save. I will try to get some time this afternoon or tomorrow to disable the add ins and test it out.

mattfraley1 avatar Apr 24 '17 18:04 mattfraley1

@romeoDo, @madskristensen I agree don't think this issue will be fixed it's been so long since it's been reported. I even offered Mads to do remote desktop session but never heard back from him

I raised the same issue for Visual Studio 2015, but it got closed for some reason https://github.com/madskristensen/BrowserReloadOnSave/issues/5

dotnetshadow avatar Apr 25 '17 01:04 dotnetshadow

I have been totally swamped with other projects in the past months, so haven't had a chance to look at it. I suspect this is in the FileSystemWatcher.Filter that the issue is. VS does some weird stuff with creating new files and renaming them on save instead of just saving the new content to the same file. Updating the Filter enum flags should do the trick I think

madskristensen avatar Apr 26 '17 15:04 madskristensen

@madskristensen Thank you so much for updating us on the issue.

We totally understand how busy you are and to be honest all your tools are pretty cool to use, so we are grateful for you developing them.

dotnetshadow avatar Apr 27 '17 00:04 dotnetshadow

Since I cannot repro the issue on my own machine, can you please help verify the fix by installing the latest CI build? It installs on top of the existing extension so no uninstall required

madskristensen avatar Apr 28 '17 16:04 madskristensen

nop, still not working... and i'm getting this in console

[19:32:41 GMT+0300 (FLE Summer Time)] Browser Link: Failed to invoke return value callback:
TypeError: Cannot read property 'files' of null

alzuma avatar May 04 '17 16:05 alzuma

I was finally able to reproduce it and fix the issue. I uploaded the new version to the Marketplace so go get it :)

Sorry for the delay in fixing this

madskristensen avatar May 05 '17 19:05 madskristensen

@madskristensen cheers I'll test it out and report back to you, thanks for all your help

dotnetshadow avatar May 06 '17 00:05 dotnetshadow