I'm writing a MVC app using Rider, and a behavior bothers me: when I modify the view, I must rebuild the solution and relaunch it to see the changes. Is it possible to see the modified view directly when I reload the site from the browser?
By the way, the IDE (or dotnet?) doesn't consider a view change to be a rebuild-triggering change. I must click on "Rebuild selected project" by hand, and then I can launch the modified version of the app. Why is that?
This is not an issue with Rider, it's fundamentally how ASP.NET MVC Core works. You need to enable Razor runtime compilation. From the docs (emphasis mine):
Razor files are compiled at both build and publish time using the Razor SDK. Runtime compilation may be optionally enabled by configuring your application.
Note that run time is not included in this list by default. To change this behaviour:
Add the Nuget package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
.
Change your Startup.ConfigureServices
code to include runtime compilation:
services
.AddControllersWithViews()
.AddRazorRuntimeCompilation();
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