![]() The full configuration and run process looks like this: The extensions monitored for are configurable. The middleware can then automatically refresh the browser. To server code changes (.cs files) you should run dotnet watch run to automatically reload the server. The Middleware is self-contained and has no external dependencies - there's nothing else to install or run. Server Side compiled code updates (combined w/ dotnet watch run).Client side static files (HTML, CSS, JavaScript etc.). ![]() You can install this middleware from NuGet: PS> Install-Package All changes auto-refresh in the browser without user intervention. Here's what the new functionality looks like in action when editing Razor Views/Pages, static CSS and HTML, and server side source code in a controller.įigure 2 - Live Reload in action on static content, Razor pages and server code.Īll that's running here (in my Rider IDE) is dotnet watch run to refresh the server when source code changes are made. You still need to run dotnet watch run for server side code restarts for hard code changes, but for all client side static and Razor file refreshing that is not required. The end result is much quicker and more reliable refreshes of content than with BrowserSync. In this post I'll describe how to build this middleware component that handles the Live Reload functionality natively in ASP.NET Core simply by hooking a couple of middleware directives into your Startup configuration. ![]() ![]() well, I got that itch to sit down and take a stab at it and the result is this ASP.NET Core Live Reload Middleware Component. While that works just fine, having to run yet another command line utility on top of dotnet watch run just to provide Live Reload functionality is a bit of a pain.Īlso in the last post I mentioned that it would be nice to build some middleware to provide the live client reloading functionality. In my last post I discussed how to integrate Live Reload in ASP.NET Core using a third party NodeJs application loaded from NPM called BrowserSync. ![]()
0 Comments
Leave a Reply. |