Problem with "Edit and Continue" in a ASP.NET core mixed Razor Pages and MVC app

281 Views Asked by At

I'm trying to update an old webpage that I had developed using MVC. Now I'm adding Razor Pages, but then Edit and Continue won't work anymore.
I can isolate/reproduce the problem in a minimal context. It seems to occur when there are files both in Pages and in Views, e.g. _ViewStart.cshtml.
Here is how to reproduce:

  • Create an ASP.NET Core Web App, .NET 5.0, No Authentication, no HTTPs, no Docker, enable Razor runtime compilation
  • Place a breakpoint in IndexModel constructor
  • Run App
  • When hitting the breakpoint, edit the code (just add a semicolon in the ctor), continue: code will compile and continue
  • Add new folder "Views"
  • Copy _ViewStart.cshtml from Pages to Views
  • Run App again
  • When hitting the breakpoint, edit the code (just add a semicolon in the ctor), continue, get message: "Edits were made to the code which cannot be applied while debugging"

I could probably work around the issue, but I'd rather try to understand why this happens. This also happens when I add the Identity package and try to customize the pages, in which case I also need a double _ViewStart.cshtml...

Any ideas?

0

There are 0 best solutions below