.NET Core - MVC

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

YetaWF Blog

Showing blog entries published on or before 03/30/2017.

Yay, Visual Studio 2017. NOT!


Warning: This is a negative writeup about web development with Visual Studio 2017 ... (some comments are PG+).

I actually have to (and try to) get work done. Visual Studio 2017 is a letdown in so many ways that I hate using it.

All of my comments apply to web development with Visual Studio 2017 and ASP.NET Core. I have no issues with C++ and C# Windows Forms (etc.) development. And mind you, I have been using VS2015, 13, 10 for similar web development, often the same ...

Incompatibilities Galore


When we set out to upgrade YetaWF to ASP.NET Core, we envisioned dual support for ASP.NET 4 MVC 5 and ASP.NET Core MVC using the same code base but embracing the new ASP.NET Core and making YetaWF fill in the gaps on ASP.NET 4. Mission accomplished! While all modules and skins are virtually 100% source code compatible (with a few strategic #if MVC6), the framework code (mostly the Core package) was not so lucky. Still, it's the same code base and we plan on supporting both ASP ...

<input> Tag Ids... Really?


ASP.NET Core MVC 1.1 has another unexpected "gift" in store. It will decorate all tags with id=property which is utterly unexpected (compared to MVC5) and utterly unnecessary. If your EditorFor(), DisplayFor(), Hidden() etc. statements don't supply an id, one is generated for you, based on the property name. But WHY? If my code doesn't ask for it, does my code really want an id?

What makes this completely untolerable is the fact that for W3C compliance no ...

Project Names and NuGet Package Names


This is no longer applicable as Visual Studio returned to using *.csproj files and project.json is no longer used.

The YetaWF solution consists of a lot of projects (500+, many of which are non open source), and includes a fair number of third-party components. While converting to MVC6, I experienced an odd error message:

Cycle detected: YetaWF2 (>= 1.0.0) -> Twil ...

Custom Razor Views cannot inherit RazorPage<T>


This was almost a showstopper.

Our views would not compile with ASP.NET Core MVC. Every single one got this error:

Property 'ViewData' is of type 'Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary`1[[YetaWF.Modules.Text.Controllers.TextModuleController+TextModelDisplay, YetaWF.Text, Version=, Culture=neutral, PublicKeyToken=null]]', but this method requires a value of type 'Microsoft.AspNetCore.Mvc.ViewFeatures ...

AdditionalMetadataAttribute Anyone?


If you developed any non-trivial MVC3-5 application, you may have used the AdditionalMetadataAttribute. YetaWF uses the AdditionalMetadata attribute to "decorate" properties for its scaffolding support. For example, when using a Url, the property is defined similar to this:

[Caption("Url"), Description("Url")] [UIHint("Url"), AdditionalMetadata("UrlType" ...

Compatibility Be Damned!


After working with ASP.NET Core MVC I have a few opinions about it. Do I like it? Yes. But, while it looks like a solid new release, with some nice new features, I can't shake the feeling that this was developed by some very smart people with absolutely no experience in the business (real) world and marginal experience with large MVC applications or maybe just a superficial knowledge of MVC5. Or maybe they just didn't care about compatibility. There are so many changes which make ...

TagBuilder ToString()


YetaWF has a fair number of templates which are used with the UIHint attribute - And a lot of code generating the required HTML for the templates. In MVC5, the TagBuilder class was used to build HTML tags. Once all tag attributes are set, the ToString() method was used to generate the tag HTML string. Unfortunately, the TagBuilder.ToString() method in ASP.NET Core MVC is not implemented, so the object.ToString() method is used instead. This of course doe ...



If you're using TagBuilder extensively in any MVC5 project, you'll eventually use SetInnerText and InnerHtml.

These always felt a bit awkward to use. ASP.NET Core MVC fixes that, but with another somewhat odd InnerHtml property which uses IHtmlContentBuilder. This collects encoded and unencoded strings and renders the entire contents using WriteTo.