This has been asked before: Why doesn't Visual Studio code formatting work properly for Razor markup?
But that question is a couple years old. And Razor formatti
I found these settings in Resharper 2019, which have improved my experience: