.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 02/27/2017.

Project Names and NuGet Package Names

02/23/2017
 

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>

02/23/2017
 

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=1.1.1.0, Culture=neutral, PublicKeyToken=null]]', but this method requires a value of type 'Microsoft.AspNetCore.Mvc.ViewFeatures ...

AdditionalMetadataAttribute Anyone?

02/15/2017
 

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!

02/13/2017
 

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()

02/07/2017
 

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 ...

TagBuilder.InnerHtml

02/07/2017
 

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.