madskristensen / BrowserReloadOnSave

A Visual Studio extension
Other
27 stars 10 forks source link

Not refreshing on reload of cshtml file #6

Closed Larswa closed 7 years ago

Larswa commented 7 years ago

Hej Mads,

Installed product versions

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 .... 🎱

dotnetshadow commented 7 years ago

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

Larswa commented 7 years ago

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

Larswa commented 7 years ago

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.

madskristensen commented 7 years ago

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

Larswa commented 7 years ago

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 commented 7 years ago

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

dotnetshadow commented 7 years ago

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

lromanov commented 7 years ago

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.

mattfraley1 commented 7 years ago

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

dotnetshadow commented 7 years ago

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?

gravidThoughts commented 7 years ago

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.

romeoDo commented 7 years ago

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?

mattfraley1 commented 7 years ago

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.

dotnetshadow commented 7 years ago

@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

madskristensen commented 7 years ago

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

dotnetshadow commented 7 years ago

@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.

madskristensen commented 7 years ago

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

alzuma commented 7 years ago

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
madskristensen commented 7 years ago

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

dotnetshadow commented 7 years ago

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

dotnetshadow commented 7 years ago

@madskristensen I just had a chance to test it, the CSS now works on reload, but CSHTML file still doesn't reload the page

I pretty much created a new .net core project edited the Views/Home/About.cshtml by adding text to some of the content and it didn't refresh the page

CSHTML - NOT WORKING CSS - WORKING JS - WORKING

Also noticed an error with browserlink not sure if it's associated image (https://github.com/aspnet/Tooling/issues/1015)

do0om commented 7 years ago

I also tested it, I have the same behavior, on my previous project:

CSHTML - NOT WORKING CSS - WORKING JS - WORKING

I still have the following error

"Browser Link: Failed to invoke return value callback:
TypeError: Cannot read property 'files' of null"

I tried to recreate a new Asp.net core project and everything works (cshtml, js, css) but can't get it working with cshtml on my first projet (same asp.net core version and same nuget packages)

dotnetshadow commented 7 years ago

@do0om @madskristensen reopened the issue here #7

harikrishnakada commented 6 years ago

Make sure you are not starting the application with debugging. For compile on the fly to work, the app must be started without debugging. Press CTRL+f5

DMW007 commented 6 years ago

@harikrishnakada Why without debugging? That's not really comfortable if you switch between C# and Razor code, which would be require a toggle between debug and starting without debug...