I upgraded DasBlog Core code base to .NET 3 several weeks ago, however, every time I would attempt a deploy to App Services it failed catastrophically with a series of HTTP 500 errors. The thing that I was not prepared for was that my self contained app contained a bunch of .NET 2.X references that would not explicitly get cleaned up during the default installation process of my new app version.

Here was the error:

2019-11-09 02:05:23.272 +00:00 [Critical] Microsoft.AspNetCore.Hosting.Diagnostics: Hosting startup assembly exception
System.InvalidOperationException: Startup assembly Microsoft.AspNetCore.AzureAppServices.HostingStartup failed to execute. See the inner exception for more details.

I admit it was a little disappointing to not really get any useful data from the diagnose blades in App Services, however, the number of ways this kind of partially incorrect upgrade could go wrong means that any kind of analysis would be difficult to codify. I finally followed the suggestions of my colleagues in the ASP.NET Core team and elected to delete the entire installation folder, except my content and themes of course, and then found that I was greeted by a 500 error of a different ilk, as follows:

2019-11-09 02:05:28.250 +00:00 [Error] Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor: The view '_BlogPage' was not found. Searched locations: /Themes/poppastring/_BlogPage.cshtml, /Views/BlogPost/_BlogPage.cshtml,
/Views/Shared/_BlogPage.cshtml, /Pages/Shared/_BlogPage.cshtml
2019-11-09 02:05:28.259 +00:00 [Information] Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker: Executed action DasBlog.Web.Controllers.BlogPostController.Post (DasBlog.Web) in 262.6212ms

According to this error the themes folder (which contains my _BlogPage.cshtml Razor view) could not be found, I was well aware that I needed to keep it around. So why was is it that a file on disk could not be found by my app?

In ASP.NET Core 3.0 runtime compilation of views is an opt-in scenario! This is the exact opposite of prior versions .NET Core, and DasBlog relied on the runtime compilation of cshtml view files in order allow you to edit or add themes on demand. As soon as I upgraded my project it precompiled all views in to an assembly (DasBlog.Web.Views.dll).

In order to turn on runtime compilation in your ASP.NET Core 3 project you add the following Nuget package:

We can then tell the app to use it by enabling Razor runtime compilation as follows:


Share on Twitter Facebook

Comment Section

Comments are closed.