So I am trying out .NET 6 for the first time. I created an empty web app based on .NET 6. It does NOT have docker support and I have changed nothing in the code.
When I run in IISExpress with the debugger (using F5) from VS2022, the site runs but each page load takes 2 seconds every time I go between "Home" and "Privacy". These are Razor pages in the sample but another app I was starting to build was also slow with controller actions. In the network tab, it is only the main request which is slow. Other js files are loaded quickly from the app and then cached.
Surely this can’t be right?
3
Answers
I have encounter the same problem, and solve it with different ways:
I know that’s not correct the issue, but it’s an helpful workaround.
Since you are saying you run with IIS Express, this may not work for you. If you weren’t actually running with IIS Express, but instead the default project executable it may.
Try the following:
Closing Visual Studio seemed key to getting it out of the 2s reload.
My .NET 6 projects were having the same 2 page load times, even after repeat visits. If I freshly ran with my project profile instead and then the IIS Express one, the issue was there with both methods. If I freshly ran the IIS Express profile, then switch it to my project that now works fine. I’m just leaving it on IIS Express for now until I find a reason not to or it gets fixed. I have no idea on the underlying issue.
I have had this exact same issue for some time – consistent 2 second page load on a fresh template MVC project (.NET 6 and now .NET 7 as well) while lightning fast if published, run in the profiler or via Postman. The solution for me was to disable ‘CSS Hot Reload’ under Options > Projects and Solutions > ASP.NET Core.