ASP.NET Core MVC

Observations about ASP.NET MVC Core and converting YetaWF from ASP.NET MVC5 to ASP.NET Core MVC. The new MVC6 has great new features. Getting there from an existing MVC 5 app is HARD!

There's Something Wrong With MVC Views

05/01/2017

For years I have always felt there is something wrong with MVC (Razor) views. (Warning: Another grumpy old man post...)

Precompiled views? That's really funny. How about "precompiled" .cs files? Well, we have those. That's what happens when you compile/build your web project. It creates assemblies which can then be deployed to your production server. And, the compiler is clever! It knows that a file hasn't been changed and doesn't need to be recompiled. That's some serious wizardry! (OK, that's some sarcasm, but directed at "precompiled" views.)

So why the f*** doesn't the same thing happen with *.cshtml files??? Instead, there's this convoluted process of precompiling views (during publish for ASP.NET Core MVC). And where do the generated assemblies go? Apparently nowhere. They're not deployable.

At least, with ASP.NET 4 we used to be able to "precompile" views on the production server with something like this:

c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Aspnet_compiler -c -p C:\Sites\Softelvdm -v /

This doesn't work with ASP.NET Core any longer (I think..., I tried...).

So now we're stuck with the slow initial site startup where every single view has to be accessed (by a site visitor) to be compiled? WTF! We have technology (well, apparently not). WHY are these views not simply compiled when I build my web project? Just like all the *.cs files? It's not like Razor processing is so much more intensive than compiling a .cs file.

No Comments

Be the first to add a comment!

Add New Comment

Complete this simple form to add a comment to this blog entry.