2023-05-01

Is hot reload supported for ASP.NET Core 6 Web API controllers?

I don't know if this a supported feature or not. I used dotnet new webapi to test the concept. I am using the .NET 6 SDK. The generated code includes a WeatherForecast controller.

I cannot get hot reload working for the code in the controller. I run the app with dotnet watch run. I am told "Hot reload enabled".

I then edit the static string array for the weather summaries and save the changes. I am told:

File changed: .\Controllers\WeatherForecastController.cs.'

and

Hot reload of changes succeeded

But when I call the API at https://localhost:7103/api/WeatherForecast, the changed values are not used. I know that it is not a caching issue because it works the same if I switch browsers to see the results of the call after the changes.

I know my setup is fine because hot reloading works if I comment out the content of program.cs and replace it some calls to write lines to the console.

I checked the article Live Code Editing - Supported changes but I do not see where it either should or should not work.



No comments:

Post a Comment