English
Français

Blog of Denis VOITURON

for a better .NET world

A shorter, more user-friendly GUID

When generating HTML code, you often need a unique identifier. A GUID works fine but it is very long (3297F0F2-35D3-4231-919D-1CFCF4035975). You can shorten it but isn’t there a more optimized (faster) way to generate an identifier in C#?


Visual Studio - Add a new file

Unlike VSCode, Visual Studio does not have a keyboard shortcut to quickly add a file in the Solution Explorer.

To resolve this issue, Mads Kristensen created the extension Add New File (64-bit).


Azure DevOps - Azure Service Connection

To deploy a website, an Azure function or a WebJob in Azure, via Azure DevOps, the easiest and most efficient way is to use the Azure Web App Deployment task.

If your Azure DevOps account is the same as the one used in the Azure portal, you will probably have no trouble to select your Azure Subscription from the list of subscriptions displayed on this screen.

However, if you need to deploy to an Azure environment that you don’t own (the customer’s, for example), it becomes much more complicated because you must first register this account in your list of Azure Subscriptions. But once this Subscription is defined, the rest is a piece of cake.

Azure Web App Deployment


Blazor - Authentication using Cookie

To authenticate a user, Blazor Server uses the same components as ASP.NET Core.

The principle is to inject the service services.AddAuthentication().AddCookie() and call the HttpContext.SignInAsync method, specifying the appropriate Claims.

But the main problem is that Blazor Server uses SignalR to communicate between the web browser and the server. This prevents the correct transfer of cookies. It is therefore necessary to define WebAPIs and to call them using Http.

Global Schema

To help you understand the development of these different steps, I have recorded a video that shows the creation of a Blazor Server project and the integration of all the steps to secure a page or components.

Video - How to create an authenticated Blazor Server project

The complete source code is available here.


Blazor - to catch a 404 not found pages.

To capture all routes that do not correspond to any existing page, there are two techniques:

  1. App.razor

This classic method consists in modifying the NotFound tag of the App.razor page. This works very well, as long as you don’t need the content of the erroneous route.


Microphone, Webcam, software for your meetings or podcasts.

Since many years now, I have been hosting the french podcast DevApps.ms, which talks about news, development and architecture of .NET technologies. On this occasion, I learned about the hardware and software that allow to produce quality podcasts. Scott Hanselman’s site helped me a lot.

For a few months now, the global pandemic has often forced us to homework. For a few days, talking with colleagues using the laptop’s microphone and camera can probably be enough. But after a few months, you probably want to have better image and sound quality.

These are two of these reasons why I want to share my experiences in choosing audio and video equipment. This equipment is certainly not of professional quality, but it has a lot of assets to improve our daily telework.

Teams-Skype


Microsoft Teams - How to create a Bot using C#

In this article, we will create a Microsoft Teams Bot developed in C#, using the Microsoft SDK. Then we will host it in Azure and publish it in your company’s Teams. This way you can easily adapt the C# code to improve the discussion with your Bot.

The steps are :

  1. Developing a Bot in C#
  2. Test the Bot locally
  3. Publish the Bot in Azure
  4. Create a Bot Channels Registration
  5. Setting up the Teams channel
  6. Create a deployment package for Teams
  7. Install the package in Teams

Windows Terminal - Display the GIT status

Recently, Microsoft released a page that explains how to customize Windows Terminal to colour and display GIT status. Git Colored


Azure DevOps - Easy Code coverage

In all projects you develop in .NETCore, it is essential to add a test project :-) And then it becomes very simple to complete this project with a code coverage calculation procedure. Developers will be asked to create test procedures that go through all the branches of your source code. A code coverage rate of at least 80% is very often recommended.


TechDay Conf 2020

This Saturday, I had the chance to participate in the first edition of TechDay Conf, it’s a virtual conference. It includes technical sessions of a few minutes. This conference is dedicated exclusively to application development, cloud transformation and new web framework like Blazor.

My two sessions today are about:

  1. Avoid Entity Framework. Do Object Relational Mapping: french speaking session.
  2. Visual Studio 2019 - Code like a ninja: french speaking session.

Languages

EnglishEnglish
FrenchFrançais

Follow me

Recent posts