Open CurlyFire opened 3 weeks ago
It sounds like you are looking to make edits to the pages while debugging the application and see the edits take effect. This is normally accomplished using "Hot Reload" rather than "Runtime Compilation". In order to get you the answers to help this forward, can you tell us what editor you are using to make the edits and what lead you to use Runtime Compilation rather than Hot Reload?
@phil-allen-msft : I am using Visual Studio directly to edit the files. The reason I was using runtime compilation is that was the technique that was used on the project before I modified it to use a razor class library, so I didn't question the technique.
@CurlyFire , given your current setup, does "Hot Reload" get you your desire to do iterative development under the debugger in Visual Studio?
@phil-allen-msft Yes it does
Goal
I am trying to edit at runtime a .cshtml view defined in a razor class library and see the effects of my modifications without restarting the application, thus achieving runtime compilation of razor views. I have followed the instructions given here:
https://learn.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-8.0&tabs=visual-studio#enable-runtime-compilation-for-a-razor-class-library
Expected results and actual results
I was expecting the edited view (defined in razor class library) to be refreshed, however when I edit a .cshtml and save it, nothing changes when I force a refresh (ctrl-f5) of the browser.
What I tried basically:
Still it did not work, so I tried this:
And now it works.
So basically my issue is: Is this the correct way ? If not what is required ? Either way, I think the documentation should be updated to be more clear. Thanks!
Sample github projet
I have created a sample project on github demonstrating the problem:
https://github.com/CurlyFire/Bug.RazorPages
Steps to reproduce: