September 19, 2017 by Anuraj Estimated read time : 4 mins
This post is about developing ASP.NET Core applications with VB.NET. I started my career with VB 6.0, and .NET programming with VB.NET. When Microsoft introduced ASP.NET Core, people where concerned about Web Pages and VB.Net. Even though no one liked it, every one is using it. In ASP.NET Core 2.0, Microsoft introduced Razor Pages and support to develop .net core apps with VB.NET. Today I found one question on ASP.NET Core Web application template in VB.NET. So I thought of creating a ASP.NET Core Hello World app to VB.NET.
First I created a VB.NET Core console application with dotnet new -lang vb -o VbConsoleApp command.
Then I modified the project file with a .NET Core Web App project file. I added the below line to the project file.
The Microsoft.AspNetCore.All reference required to build ASP.NET Core apps. Then I modified Program.vb code and added BuildWebHost code.
Here is the code.
Then I created the Startup class and added following code.
In this post I am using ASP.NET MVC. So I created a controller class and a model class.
In the code I have created a method, which returns a collection of model objects.
Now you can run the app with dotnet run command.
Once it started, you can browse the app as usual with localhost:5000 URL. Next tried with MVC Views, for that I have created a another controller, Home Controller and created an Index method.
Then I created a Razor View, Index.vbhtml, then added in Views/Home folder. And when I tried to access localhost:5000, it failed. The exception logged was view index was not found.
As ASP.NET Core is yet to support looks like there may be some changes required to support .vbhtml files.