.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 08/30/2018.

Goodbye Razor


Goodbye Razor. You were a good idea whose time has passed.

Razor sure simplified writing/mixing C# andf HTML and rendering HTML. We used to be able to write cshtml pages, hit F5 in our browser to load the new page. That was pretty useful. With ASP.NET Core, that's no longer the case. You have to restart the site before the cshtml page gets recompiled.

Compiling/verifying cshtml files was always possible (in ASP.NET 4) with a command line tool. With ASP.NET Co ...

WebAssembly - The Holy Grail of Web Development


WebAssembly, it's real, it's coming and it's going to take over web development. Well at least, once it's ready.

They call it "binary" code. Well, maybe, but not really, it's a superfast subset of JavaScript. Preparsed and ready to run. There are compilers that will translate C/C++ to a WebAssembly (really the JavaScript subset that's superfast).

There are compilers that will translate other langu ...

Client-Side Versus Server-Side Frameworks


Client-side JavaScript frameworks have become very popular. Angular, React, Vue, and many others are available to create your state-of-the-art Single Page Application (SPA).

While I consider myself slightly slanted towards server-side development, I'm equally comfortable developing in pure JavaScript, jQuery, and many client-side frameworks. Do I want to work on JavaScript code or a client-side framework? Not really. I find it somewhat tedious and a bit akwar ...

TypeScript and JSX without React


I'm a big fan of React. I also love JSX. And TypeScript, or really anything that's more type-safe than JavaScript.

Unfortunately, I don't have the luxury of rewriting all the sites I have in React. All the sites I maintain and run are based on YetaWF. It offers Single Page Sites, Static Pages, but doesn't use any of the "cool" new frameworks. Instead, it implements its own framework where server-side and client-side work closely together to accomp ...

ASP.NET Core MVC Preview 2 - But VS 2017 Still Sucks


This post is no longer relevant as Visual Studio 2017 has seen a fair number of improvements over time.

ASP.NET Core MVC 2.0 Preview 2 again supports .NET, so YetaWF is again up and running with ASP.NET Core MVC (see the demo site).

But it wasn't exactly trivial to get it up and running. Opening the solution the first time took 20 minutes (not kidding). And the second time. And everytime thereafter. ...

AJAX GET and Query String Length


While implementing Unified Page Sets (a.k.a. Single Page Site) in YetaWF, I decided to go with Google's recommendation to Use GET For AJAX Requests, in this case to swap portions of the page in and out.

Well, it worked for a while... But soon this happened:

HTTP Error 400. The size of the request headers is too long

AJAX GET requests will cram all ...

Support Dropped For ASP.NET Core MVC


Update: This post is no longer relevant as YetaWF supports ASP.NET Core 2.0 since YetaWF version 3.0.0.

Update: A few hours later, it was announced that ASP.NET Core 2.0 will support netstandard2.0. All is well. As soon as ASP.NET Core preview is updated for netstandard2.0, we will resume support for ASP.NET Core.

Update (7/5/2017): Unfortunately ASP.NET Core 2.0 Preview 2 is still unusable, mainly because of Visual Studio 2017 ...

2017 So Far Has Been Wasted On ASP.NET Core MVC


In January 2017 I decided it was time to "upgrade" YetaWF from MVC 5 to the new ASP.NET Core MVC. Oh, and how much fun it was (Not!). I spent about 2 months converting silly (and major) things which changed between MVC 5 and ASP.NET Core (see Incompatibilities Galore). So, after two months I had a working, deployable version of YetaWF. Was it any better than the vers ...

VarChar or NVarChar Is Never The Question


So, if you had asked me yesterday whether YetaWF data is stored as UNICODE in SQL tables, I would have said "Of Course!". Since YetaWF supports localization, we have to.

Well, assumptions are a death sentence for any developer. But how could I be wrong? I wrote all of YetaWF (well, except for all the add-ins, courtesy of the open source community). I "meant" for data to be stored in UNICODE. And it seem ...

There's Something Wrong With MVC Views


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

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.