RickStrahl / Westwind.AspnetCore.LiveReload

ASP.NET Core Live Reload Middleware that monitors file changes in your project and automatically reloads the browser's active page
Other
469 stars 42 forks source link

How to troubleshoot when it does nothing at all? #38

Closed szalapski closed 3 years ago

szalapski commented 4 years ago

I have just tried implementing LiveReload on my Blazor WebAssembly site, following the directions to bring in package Westwind.AspnetCore.LiveReload 0.2.10 to my Server project, customize my Startup.cs, add the watch to my project file, and ensure my appsettings are right. Everything seems good. A change to a .razor file triggers a rebuild and restart via dotnet run. However, this change or a change to a .css file causes nothing to happen in my browser. It seems as if whatever Javascript or other content is necessary doesn't exist.

How can I troubleshoot this? Is there certain Javascript I should look for on the page? What am I missing?

Server project has <TargetFramework>netcoreapp3.1</TargetFramework> and appsettings including:

  "LiveReload": {
    "LiveReloadEnabled": true,
    "ClientFileExtensions": ".css,.js,.htm,.html,.ts,.razor,.cs",
    "FolderToMonitor": "~/.."
  },

Client project has <TargetFramework>netstandard2.1</TargetFramework> and <Watch Include="**\*.razor;**\appsettings.*" /> in csproj

RickStrahl commented 4 years ago

This tooling is really not designed for client side Blazor, but for server side applications, so even if it works it's very, very slow due to the recompilation requirements of Blazor code upon changes and it will only work at all if server side code also available (since the server restart is what triggers the refresh).

I haven't looked at the Blazer WA in some time, primarily because that simply not the use case for this.

szalapski commented 3 years ago

I have had it working great on another Blazor WebAssembly project, and I see no relevant differences, so I'm not sure why one works and the other doesn't. It isn't that slow, as the recompile typically takes about 5 seconds. I'll keep trying it, but if you learn anything, I'd love to know. (Even without it, I still use dotnet watch run and then I have to hit F5 in my browser.) By the way, this is for a client that's served up by a server, not for a PWA, so it should be similar to a ordinary ASP.NET web site--it doesn't need to care about Blazor at all.

RickStrahl commented 3 years ago

Closing this since the title doesn't really match the issue.

I will at some point review Blazor loading, but for the moment that's not part of the intended use case for this tool.

szalapski commented 3 years ago

I have discovered that I can get it working quite well if I just put app.UseLiveReload(); after app.UseResponseCompression() in the middleware pipeline (rather than before it), in Startup.cs method Configure. Any idea why response compression would break it?