Razor Html Partial doesn't update when debugging

Using Core 1.0.40 with a very simple site using a cshtml page that contains a partial reference:

@Html.Partial("MyPartial", modelObject)

When debugging, I can change the main cshtml file and refresh the browser to see the changes.

But if I change the partial file (e.g. MyPartial.cshtml), the changes aren’t reflected unless I stop and restart the debugger session. I guess it’s being cached.

Is there a way to force it to reload the partial file?

In .NET Core we don’t have any control over the compilation as MVC is used to perform the compilation and view rendering.

Ok, thanks.

Well, by trial and error, I found out how to make it work…just in case anyone else finds this and has this same problem. You have to add the cshtml extension.

This will show any changes while debugging:

@Html.Partial("MyPartial.cshtml", modelObject)

but this won’t

@Html.Partial("MyPartial", modelObject)
2 Likes

no kidding, that’s good to know, thx.