0

Running the template blazor .Net 5 application in vS21019, I notice that any changes I do in the .cshtml files are not shown while running the application in debug (refresh has no effect).

Probably because razor content is not re-compiled during execution.

Added the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation Nuget package, as I thought it might help, but it has no effect.

https://learn.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-3.0&tabs=visual-studio.

Is this possible? I'm used to do runtime design changes, so I really miss not having the option here.

enter image description here

Kman
  • 4,809
  • 7
  • 38
  • 62
  • Yes. It does not give me the answer I would like, but it does answer my question. Thanks – Kman Jan 11 '21 at 20:55

1 Answers1

1

Best you can do in Blazor right now is to run from the console with

dotnet watch run debug

There is no real hot reload in blazor yet, and that package you found is for MVC, not Blazor.

Make sure to add project settings to tell the watcher what to watch so it does not watch everything. While trying to find resources on this I came upon this thread that adds tons more information and a few more ideas Better StackOverflow thread on hot reloading in blazor

EDIT: Here is a screenshot of another VS setting that does about the same - I keep it to None usually because I want control on when things build, but you can try playing with it

enter image description here

rdmptn
  • 5,413
  • 1
  • 16
  • 29
  • Thank you. Not quite was I was hoping for. I hope they'll add it soon. I am so used to hot reloading, that it's tempting to back to regular MVC :) – Kman Jan 11 '21 at 20:54