.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/28/2020.

Don't Let System.Data.SqlClient Happen To You!

02/03/2020
 

I spent about a week chasing a "mysterious" hang in my application. While it was somewhat easy to recreate, I had no clue why it was hanging. Always on ExecuteReaderAsync.

This is an ASP.NET Core 3.1 application. The code that ended up hanging is quite old and used in many other sites, so I was stumped. I started refactoring, cleaning up some async/await stuff that looked suspicious, even though it had been in use for a few years and still is in some other sites. Everyt ...

ASP.NET Core 3.0 - Finally, 3 Years Later

10/10/2019
 

Almost THREE years after picking up ASP.NET Core, 1.1 at the time, things are finally shaping up and ASP.NET Core is ready for prime time. I'm about to convert the last website to use ASP.NET Core.

I managed to keep YetaWF source code shared between ASP.NET 4 and ASP.NET Core with the same feature set, but it's time to cut the cord and switch to ASP.NET Core completely. The performance using ASP.NET Core 3.0 is simply a lot better. And runs on Linux and Docker too.

Hav ...

Dotnet Publish Creates Invalid EXE

10/06/2019
 

Upgrading to ASP.NET Core 3.0 went pretty smoothly overall, and first indications show overall page load time improved by nearly 20%. Given there were no changes to YetaWF, I have to assume that's all thanks to 3.0, maybe endpoints?

But then it came time to publish the first site. And it didn't work. Investigation showed, the EXE on Windows 10 built for deployment with IIS simply did not load. It pretended to run, but it didn't.

I noticed I had an <Outp ...

100% SPA, 100% ROCA, Well Almost

11/08/2018
 

I mentioned before, that YetaWF is by default a Single Page Application here. Sometimes I ignore academia or the latest technical theories. Instead I focus on what what I need to get done. That's how YetaWF was created, because I needed something to run company sites. Over the years it has evolved from simple framework to a full blown SPA, ASP.NET Core MVC framework, with super-fast cu ...

Goodbye Razor

08/27/2018
 

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

12/07/2017
 

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

10/31/2017
 

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

08/02/2017
 

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

07/21/2017
 

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

06/10/2017
 

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

05/10/2017
 

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

05/09/2017
 

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

05/07/2017
 

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

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

Yay, Visual Studio 2017. NOT!

03/20/2017
 

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

03/11/2017
 

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?

02/28/2017
 

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

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