Tag Archives: dotnet

.NET 5, Blazor and more in 2021!

By Shahed C on January 4, 2021

Update: Due to new personal commitments and more work commitments in 2021, I wasn’t able to make much progress with my weekly C# A-Z series on dev.to/shahedc.
For now, I’ll focus on some new content for my regular blog (this blog, WakeUpAndCode.com) and hope to revisit the A-Z series with .NET 6.

Original Post:

I published my first ASP .NET Core A-Z series on WakeUpAndCode.com back in 2019, from January to June 2019. I followed this with a new A-Z series in 2020, simultaneously mirroring the posts on dev.to as well.

Going forward, my next A-Z series will cover 26 topics covering various C# language features. The C# A-Z series will be featured exclusively on my dev.to site under the .NET org:

Preview of C# A to Z series on DEV

Meanwhile, this site (WakeUpAndCode.com) will continue to feature new ASP .NET Core content based on .NET 5, Blazor and more! To get a sneak peak of what’s to come, check out my guest appearance on the .NET Docs Show (livestreamed Dec 7, 2020). You may jump ahead to 58:05 in the video for the sneak peek:

The above video teases my upcoming cinematic visualizer app, which will allow the end user to connect the dots within a cinematic universe, e.g. the Marvel Cinematic Universe. The source code will allow any .NET developer to learn more about C# and .NET 5, ASP .NET Core, Entity Framework, Azure App Service, Bot Framework, Azure Functions, and more!

High-Level Diagram of Cinematic Visualizer

The goal of the web app is to make use of all 3 project styles available in ASP .NET Core:

  • MVC (Model View Controller)
  • Razor Pages
  • Blazor
ASP .NET Core web architecture

Developers frequently ask the developer community (and Microsoft) whether a particular web project type is preferred over the other. Last year’s blog series built upon the NetLearner web app by duplicating identical functionality across all three project types. This year, the cinematic visualizer app will attempt to use each project type of something specific.

  • MVC for data entry
  • Razor Pages for the Portal site
  • Blazor for the highly interactive portion

The above choices aren’t necessarily prescriptive for the type of web apps they will demonstrate. However, they should provide a starting point when developing ASP .NET Core web applications.

Debugging Multiple .NET Core Projects in VS Code

By Shahed C on October 13, 2020

Introduction

Originally written up in a GitHub repo while helping out another developer, this blog post explains how you can debug multiple .NET Core projects in Visual Studio Code.

To download the sample code, clone the following GitHub repository:

Opening VS Code

Launch VS Code with the project root as the current working directory. One easy way to do this is to type the word “code” followed by a dot “.” at a Command Prompt, Powershell window or Windows Terminal.

Powershell/Terminal Command:

code .
Powershell Command

If you already have VS Code open, use the built-in Terminal (Ctrl+`) to change the current directory to the project root.

In either case, you should end up with VS Code open with the Terminal open in the correction location (project root).

VS Code with Terminal panel

Launch Configuration

This project contains launch.json configuration for a .NET Core console project and a Web API projet.

Web API Launch Config
Web API Launch Configuration
Console Project  Launch Config
Console Project Launch Configuration

Debug Panel

In the Debug Panel of VS Code, observe that you can see both configurations, ready for launch.

Web API in Debug Panel
Web API in Debug Panel
Console Project in Debug Panel
Console Project in Debug Panel

Setting Breakpoints

In the code for each project, set a breakpoint that’s easy to identify.

Breakpoint in Web API project
Inside Get() method within WeatherForecastController.cs in Web API project 
Breakpoint in Console project
Console.WriteLine in Console project 

Debugging with Breakpoints

From the aforementioned Debug Panel, run the Web API project and then the Console project by clicking the Play/Debug button for each launch configuration.

Note: when the web browser launches at the root of the website, you may browse to the WeatherForecast Controller manually, e.g. https://localhost:5001/WeatherForecast

You should see each program pause at the breakpoints you set earlier.

Breakpoint in Web API project
Breakpoint in Web API project
Breakpoint in Console project
Breakpoint in Console project

Continue Running

Press the Play/Continue button to continue running while debugging. Observe the output in a web browser (for the Web API project) or the Terminal within VS Code (for the Web API project)

Output in Web API project
Output in Web API project
Output in Console project
Output in Console project

Optional: Run Multiple Projects

As a bonus, I have added a Compounds section to the launch.json file.

    "compounds": [
        {
            "name": "Both Console & Web API",
            "configurations": [
                ".NET Core Launch (console)",
                ".NET Core Launch (web)"
            ]
        }

This will allow you to launch both the Console app (in the Terminal) and the Web API app (in a browser) in rapid succession, with 1 click.

Debugging multiple projects
Debugging multiple projects