Open Source Project Creates ASP.NET Core Apps with VB.NET

"I think we can say that VB.NET finally made it to ASP.NET Core," developer Mohammed Hamdy Ghanem told Visual Studio Magazine about his new open-source project.

The project, eShopOnWeb in VB.NET (.NET Core 3.1), as its name suggests, involves converting the open-source eShopOnWeb sample ASP.NET Core 3.1 reference application to VB.NET.

That .NET Foundation GitHub project is described as a "Sample ASP.NET Core 3.1 reference application, powered by Microsoft, demonstrating a layered application architecture with monolithic deployment model."

Ghanem relied on other tools of his own making (under his VBAndCs GitHub repository) in his eShopOnWeb conversion effort.

"I created a VB.NET version of this app, using Vazor and ZML to design MVC views and Razor Pages, because ASP.NET Core doesn't provide a Razor syntax that supports VB.NET," Ghanem told VSM.

His Vazor project is described as "a VB.NET Razor for ASP.NET Core 3.1 (MVC and Razor Pages)." ZML is described as "The XML Razor for C#, VB.NET and F#."

Ghanem's eShopOnWeb in VB.NET effort, targeting .NET Core 3.1, consists of three projects:

  • ApplicationCore.vb: a VB.NET .NET standard library project that contains database entities and expressions needed to configure EF Core.
  • Infrastructure.vb: a VB.NET .NET standard library project that defins the data repository, database context, data megrations, and other services.
  • Web.vb: a VB.NET ASP.NET Core 3.1 project, that contains MVC views and Razor Pages that designs the website.

"It all started in 16 Mar 2019, when I tired [of] waiting to get vbhtml support in Razor, so, I decided to do it myself," said Ghanem, who lives in Egypt. "I got the source of ASP.NET Core project, but failed to build it on my machine, as it was a transitional period to VS.NET 2019 and .NET Core 3 and seems I missed something. Without a compiled source that I can trace, and with the lack of documentation about this source, I gave it up, and decided to go another way."

Mohammad Hamdy Ghanem
Mohammad Hamdy Ghanem (source: GitHub).

After many trials and tribulations, he eventually got things to work.

"I hope VB.NET developers found it useful, and start creating their web applications targeting ASP.NET Core 3.1 using VB.NET and Vazor," Ghanem said.

He said there is still some work that he needs to do:
  • I need to provide auto completion for Tag Helpers and ZML tags.
  • I am working now on creating a real Vazor View Engine. Yes, I iam going back to complete the original VBRazor idea, which can make using tag helpers in vbxml easier and more powerful. This will be an upgrade to Vazor, and will not brake any existing Vazor code.

In the meantime, Ghanem pointed out more possibilities around the project.

"@AnthonyDGreen, a former VB.NET project manager, picked up the XML literal idea and started to put its powerfulness in use in Pattern-Based XML Literals, which leveraged the idea to use not only in ASP.NET Core, but also WPF and Xamarin. This is why I froze my Vazor for a year waiting for his work to be released someday in VB.NET, but unfortunately, he quit Microsoft last January, and VB.NET was declared frozen in March 2020 with no new changes to the compiler anymore, so, I had to go back to my Vazor and go on."

Although, as Ghanem mentioned, Microsoft last month announced "We Do Not Plan to Evolve Visual Basic as a Language," Ghanem is a big fan of his programming language of choice. "It is amazing that I discover every time that all gradients are there in VB.NET ready to be used. It is a waste to let such a powerful language go away."

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus


Subscribe on YouTube

Upcoming Events