About the course "ASP.NET: Databases"

So I just started this course: https://www.codecademy.com/courses/learn-asp-net/lessons/asp-net-data-projects/exercises/asp-net-data-projects-template

There’s nothing wrong with the course itself so far, but as I like to recreate the exercises with Visual Studio, there is a problem. The very first command in the course is

dotnet new webapp -o . -n RazorCountry

and when I do that on Visual Studio terminal I end up getting a different project to the one on Codecademy course. For example there is no Main() method in my Program.cs nor namespace at all. Instead the code in my Program.cs starts as follows…

var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddRazorPages(); var app = builder.Build();

Why am I not getting the same project as on the ASP.NET course? I’m at a complete loss here.

Welcome.

One thing to bear in mind is that the languages and technology covered by the courses aren’t set in stone. Programming languages, much like spoken ones, evolve over time and the technology underpinning them changes as well.

These changes aren’t automatically reflected in the learning material, and unfortunately I have no information which I can share on the frequency with which courses are reviewed and updated.

The course you’re referring to uses version 3.1.417 of the .NET SDK - you can check this by running dotnet --version from the bash shell:

I suspect that if you’ve installed Visual Studio, you’re likely using a recent release which will have a newer version of the .NET SDK.

If you look at the .NET SDK documentation, specifically for the webapp template type, you’ll see that for .NET SDK versions 6.0.300 and onwards there’s an additional flag available: --use-program-main.

I would imagine that using that flag would generate the expected boilerplate to match the learning environment, but it might be worth checking your .NET version before trying.

1 Like