Over a million developers have joined DZone.

Simple .NET Core Application Using VB.NET

DZone 's Guide to

Simple .NET Core Application Using VB.NET

We take a look at how to create a simple .NET Core application using the sometimes-overlooked VB.NET. Come find out just how easy it is!

· Web Dev Zone ·
Free Resource

.NET Core 2 Preview 1 brings us support for VB.NET on .NET Core. Although tooling for web applications is not ready yet we can start with console applications and also some web applications like I will show in some of my later posts. Visual Studio 2017 Preview 2 is needed to try VB.NET out on .NET Core. This blog post is a short demo about how to build a simple utility application on .NET Core 2 Preview 1 using VB.NET.

What about ASP.NET Core and VB.NET? It’s coming, I’m sure. I was able to write Pages and MVC applications on VB.NET, but failed to get views working with tag helpers. Web based APIs that don’t require views can be written on VB.NET already.

Let’s write a simple VB.NET application that runs on .NET Core. We start by creating a new application.

.NET Core Console App on VB.NET

As a result, a new application with Program.vb file is created. By default, Program.vb contains just a Main sub for application startup.

The application will download to a robots.txt file and saved to your disk. So, it’s a simple utility application. The code is here:

Imports System.IO
Imports System.Net   Module Program
    Sub Main(args As String())
        Dim request As WebRequest           request = HttpWebRequest.CreateHttp("http://www.w3.org/robots.txt")
        Using response As WebResponse = request.GetResponse(),
              file As FileStream = New FileStream("robots.txt", FileMode.CreateNew)               response.GetResponseStream().CopyTo(file)
        End Using         Console.WriteLine("Press Enter to continue ...")
    End Sub
End Module

After running the project there is a robots.txt file in the project root folder.

Wrapping Up

.NET Core 2 enables VB.NET developers to join the .NET Core world. VB.NET is here and will be fully supported by the .NET Core family from .NET Core 2 on. And it’s already possible to write utility applications on .NET Core using VB.NET. Also, writing web applications is supported, but the tooling is not ready yet. While VB.NET is not yet fully compatible with .NET Core, it’s a good idea for VB.NET developers to start playing with it today.

vb.net ,web dev ,.net core ,web application development

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}