I recently upgraded an .Net Framwork AspNet MVC app to a AspNet Core 3 MVC app and I'd like the ability to change a view, save, and refresh my browser window to see the changes. Now it appears I have to do a build every time before I can see any changes. Is there a way to change this behavior?
This is being hosted under IIS 10
To force the app to rebuild and restart, use the keyboard combination Ctrl + R in the command shell. When an unsupported code edit is made, called a rude edit, dotnet watch asks you if you want to restart the app: Yes: Restarts the app.
CSS Hot Reload: You can change CSS files while the app is running, and changes are applied immediately to the running app as you type. No Debugger: You get Hot Reload support when using Visual Studio to start your web app without the debugger (CTRL-F5).
First, enable it in your IDE settings: On Windows, check the Enable XAML Hot Reload checkbox (and the required platforms) at Tools > Options > Debugging > Hot Reload. In earlier versions of Visual Studio 2019, the checkbox is at Tools > Options > Xamarin > Hot Reload.
Hot reloading allows you to see the changes that you have made in the code without reloading your entire app. Whenever you make any changes, all you need to do is save your code. As soon as you save your code, React Native tracks which files have changed since your last saved, and only reload those file for you.
As far as I know, the runtime compilation could just work in the develop environment. That means you couldn't use it in the production environment(which is hosted on the IIS).
If you change the visual studio's debug environment to IIS, it will stil work.
Besides, RuntimeCompilation is not a build-in feature in the asp.net core 3.0.
If you want to use it, I suggest you could try to install the package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
and then configure AddRazorRuntimeCompilation
in Startup.cs
like
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews().AddRazorRuntimeCompilation();
}
There is a new way of doing this for 3.1, taken from: https://learn.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-3.1
Add the package at csproj
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.3" />
Then at launch.json, add a new environment variable
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
I was very happy to implement Westwind.AspnetCore.LiveReload per this blog post. It was quite easy and worked better than BrowserSync.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With