Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not refreshing on reload of cshtml file #6

Closed
Larswa opened this issue Dec 4, 2016 · 25 comments
Closed

Not refreshing on reload of cshtml file #6

Larswa opened this issue Dec 4, 2016 · 25 comments

Comments

@Larswa
Copy link

Larswa commented Dec 4, 2016

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

@dotnetshadow
Copy link

dotnetshadow commented Dec 8, 2016

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
Copy link
Author

Larswa commented Dec 8, 2016

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

@Larswa
Copy link
Author

Larswa commented Dec 8, 2016

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
Copy link
Owner

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

@Larswa
Copy link
Author

Larswa commented Dec 14, 2016

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
Copy link
Author

Larswa commented Dec 14, 2016

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

@dotnetshadow
Copy link

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

@lromanov
Copy link

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
Copy link

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

@dotnetshadow
Copy link

dotnetshadow commented Mar 9, 2017

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
Copy link

gravidThoughts commented Mar 13, 2017

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
Copy link

romeoDo commented Apr 23, 2017

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
Copy link

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
Copy link

dotnetshadow commented Apr 25, 2017

@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
#5

@madskristensen
Copy link
Owner

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
Copy link

@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
Copy link
Owner

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
Copy link

alzuma commented May 4, 2017

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
Copy link
Owner

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
Copy link

dotnetshadow commented May 6, 2017

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

@dotnetshadow
Copy link

dotnetshadow commented May 6, 2017

@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
(aspnet/Tooling#1015)

@do0om
Copy link

do0om commented May 6, 2017

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
Copy link

@do0om @madskristensen reopened the issue here #7

@harikrishnakada
Copy link

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
Copy link

DMW007 commented Aug 25, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests