fabiochiu/medium-articles huggingface dataset:
Running a .NET Project. C# From Scratch Part 2.2
By: Ken Bourke
Tags: Programming, Dotnet, Learn To Code, Csharp, Software Development

We know that the application is working since it produces the default output, but what exactly is happening when we use the dotnet run command?

Behind the Scenes

When you use the dotnet run command, .NET automatically does several things to make your project ready to run. In this section, we’ll look at the steps .NET takes behind the scenes to run your application.

Restore

The first thing that happens is .NET implicitly runs the command ‘dotnet restore’. The dotnet restore command tells .NET to go out and get the correct version of any packages used by your application.

Packages are pieces of codes that other developers have written and you can use in your application. In the world of .NET, the package system is called NUGET.

All of the packages being used by your application are recorded in the .csproj file, along with the version of the package being used. When the dotnet restore command is executed, .NET goes out and gets each package listed in your .csproj file from the internet.

The packages that are used in your application are called external dependencies.

In our basic project, we don’t have any external dependencies so nothing happens when .NET runs this command.

Build

Next, .NET runs the ‘dotnet build’ command implicitly.

This command tells .NET to compile your source code files into a binary file that can execute on your machine.

The tool that does this is the C# compiler. The C# compiler takes all of the source code files in your project as an input and outputs a single binary representation of your source code. This binary format is faster to execute on your machine.

The output file is a dll file.

Dll stands for Dynamic Linked Library. In .NET, this is referred to as an assembly.

Run

Finally, the dotnet run command is executed.

This command tells .NET to bring the application to life using the .NET Core Runtime and to execute the instructions in the dll file.

It’s important to note that if you want to run your application, you need to use the .NET Core Runtime. It’s not possible to run the application via the dll file directly.

This is because it’s the .NET Core Runtime that knows how to launch your application, manage memory, convert the instructions in the dll file into instructions that your processor understands and tear down the application when it’s finished running.

What’s Next?

In this part of the series, we learned how to run a .NET application using the dotnet run command. We also learned what .NET is doing in the background to convert our project into an application that can be run on our machine.

In the next part of the series, we’ll learn how to open the project in Visual Studio Code and look at the most important parts of our code editor. You can find that part of the series here.
How can I access an iFrame from the codebehind file in ASP.NET
By: Ravi Kumar
Tags: Aspnet, Mvc, Dotnet

How can I access an iFrame from the codebehind file in ASP.NET Ravi Kumar ·Dec 13, 2020

In this blog post, you will learn using iframe in asp.net c# and how to set iframe src dynamically in asp.net codebehind file. iframes are an easy way by which you can embed another page within your original page.
Criando um PWA de “Planning Poker(Scrum)” com Blazor WebAssembly
By: Jonathas Tassi E Silva
Tags: Blazor Webassembly, Front End Development, Blazor, Dotnet, Blazor Components

Usando Github Actions, toda vez que é feito git push para a branch main do repositório, é gerado um novo deploy e disponibilizado no Firebase Hosting. Pretendo falar sobre isso no futuro, mas caso queira ver o script do Github Actions, acesse esse link. https://github.com/jonathastassi/PlanningPoker.WebApp.Blazor/blob/main/.github/workflows/main.yml.

URL da demonstração: https://planningpoker-webapp-blazor.web.app/

name: Deploy to Firebase Hosting

# Run workflow on every push to the master branch

on:

push:

branches: [ main ]



jobs:

deploy-to-firebase-hosting:

# use ubuntu-latest image to run steps on

runs-on: ubuntu-latest

steps:

- uses: actions/checkout@main



#sets up .NET Core SDK 5

- name: Setup .NET Core SDK

uses: actions/setup-dotnet@v1.7.2

with:

# SDK version to use. Examples: 2.2.104, 3.1, 3.1.x

dotnet-version: 5.0.101



# publishes Blazor project to the release-folder

- name: Publish .NET Core Project

run: dotnet publish PlanningPoker.WebApp.csproj -c Release -o release --nologo



# copy index.html to 404.html to serve the same file when a file is not found

- name: copy index.html to 404.html

run: cp release/wwwroot/index.html release/wwwroot/404.html

# send files to Firebase Hosting

- uses: FirebaseExtended/action-hosting-deploy@v0

with:

repoToken: '${{ secrets.GITHUB_TOKEN }}'

firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_PLANNINGPOKER_WEBAPP_BLAZOR }}'

channelId: live

projectId: planningpoker-webapp-blazor

env:

FIREBASE_CLI_PREVIEWS: hostingchannels
💠 Clean Architecture End To End In .NET 5
Tags: Programming, Code, Better Programming, Ｍedium, Dotnet

Introduction

Hello everyone, in this article we are going to cover clean architecture with end to end support in ASP.NET 5.0. As we all know, its newly launched Framework officially released in the month of November. Here I am sharing the link to install the SDK for .NET 5

What we are going to cover in this .NET 5 Clean Architecture?

Entity Framework Code First Approach Dependency Injection Automapper JWT Authentication Versioning of API’s Swagger (Versioning)

Packages used in this Project!

AutoMapper.Extensions.Microsoft.DependencyInjection Microsoft.AspNetCore.Authentication.JwtBearer Microsoft.AspNetCore.Mvc.Versioning Microsoft.EntityFrameworkCore Microsoft.EntityFrameworkCore.Design Microsoft.EntityFrameworkCore.Relational Microsoft.EntityFrameworkCore.SqlServer Microsoft.EntityFrameworkCore.Tools Newtonsoft.Json Swashbuckle.AspNetCore Swashbuckle.AspNetCore.Newtonsoft

Step 1

Create a Project in Visual Studio

Step 2

Make Sure to Select the ASP.NET Core 5.0 and enabling the OpenAPI support helps to add the swagger by default in our project without installing manually again.

Step 3

Entity Framework Code First Approach

Create a Class library (.NET Core) named DataAccessLayer, which contains:

ApplicationDbContext

Wrapping all the classes using conventions:

Entity Mappers

Creating a Tables with relations using Model Objects

Migrations

Includes all our Migrations respective to tables which we are consuming

Models

Defining the Table Models using Classes

Seed Data

Static Data for Tables.

Folder Structure

Here i am maintaining the Folder Structure to have a deeper undestanding and naming conventions as per my standard.

Dependency Injection

Create a Class Library(.Net Core) named as Services in which we are maintaing all the Business logic and Core Functionality.

Folder Structure

Mapper : Automapper — Obeject — Object Mapping

Repository Pattern using Interfaces

Common model

JWT Authentication, Swagger & Versioning

I followed C# Regions to improve the code readability, so in this configure services, I have separated everything with regions

Startup.cs

appsettings.json

Used to store configuration settings such as database connections strings, any application scope global variables.

UserController

BaseController

RolesController

Basically, I have set up everything in the BaseController and invoking this base to all the controllers in order to authorize and for routing. Below is the GitHub link to clone the project.

Github Repo

This is the entire end-to-end clean architecture with the latest .NET 5, I hope this article helps you. Give it a Clap 👏

Keep learning!!!
[C#]判斷檔案是否為TXT
Tags: C Sharp Programming, Dotnet

以讀取檔案Binary判斷是否為txt

public bool IsTextFile(string path)

{

using (StreamReader reader = new StreamReader(path))

{

int Character;

while ((Character = reader.Read()) != -1)

{

if ((Character > 0 && Character < 8) || (Character > 13 && Character < 26))

{

return false;

}

}

}

return true;

}
Building Multi-platform apps with React, Cordova, CouchDB/PouchDB, .NET, Kubernetes and Azure
By: Tudor Dumitriu
Tags: Couchdb, Tech, Cordova, Kubernetes, Dotnet

This is a series of posts on how we’ve built a multi platform application (web SPA and mobile), with real time data sync and offline-first capabilities, while being hosted in the cloud.

The targeted audience consists of software architects, developers and even CTOs, that are looking for alternative, proven, tech stacks, but not limited to that, since it has a higher technical level.

But, stakeholders and decision makers can take into consideration for similar use cases because this stack has quite some things to offer. Starting with the fact that it can deploy same code base on multiple platforms (web, iOS, Android), it uses battle tested frameworks and libraries, it avoids cloud vendor lock it because it’s running on Kubernetes and Docker, and so much more, so we think there’s a gain for everyone.
Working with the .NET CLI. C# From Scratch Part 2.0
By: Ken Bourke
Tags: Programming, Dotnet, Csharp, Learning To Code, Software Development

Welcome to another part of the series C# From Scratch, a course dedicated to teaching you everything you need to know to be productive with the C# programming language.

In the previous part of the series, we learned what .NET does for our applications and why we need it to run applications we write in C#. That part of the series is available here.

In this part of the series, we’ll get hands on with the .NET Command Line Interface, a tool that is installed as part of the .NET SDK to make developing .NET applications easier.

Accessing the .NET CLI

The .NET Command Line Interface is installed on your machine as part of the .NET SDK installation.

Once the .NET CLI is installed on your machine, you can access it through a Command Prompt window (also known as a terminal or shell depending on your operating system).

On a Windows machine, you can launch the command prompt by going to the Start menu and typing ‘cmd’. Press enter to launch the Command Prompt app.
Extracting Service Configuration in Dotnet 5
By: Taylor Goodall
Tags: Dotnet 5, Programming, Best Practice Advice, Dotnet, Software Development

A trusted pattern for keeping your config seperated and clean

Photo by Timothy Dykes on Unsplash

This blog posts is a simple guide on how we can extract services from our startup.cs file separate configuration files allowing us to have dedicated configuration and keep our main startup.cs file as minimal as possible.

by default in ASP.net core 5 we get Swagger out of the box, let’s start with extracting this out to to its own configuration file

We can extract out the above code to a SwaggerConfig.cs file which will contain all of our swagger specific configuration as required. I have created a Configurations folder in the root of my project

We can then go ahead and Register this to our services in startup.cs Don’t forget to import the namespace of your configuration as well.

we can also extract Swagger Configuration shown below

This can be done by adding the below method to our SwaggerConfig file

then update the ConfigureServices method to be

We can also use this pattern to bootstrap our own services and keep our startup as minimal as possible, You can break your services out as needed, for example you may want all of your repositories in a separate configuration file

Update startup.cs as follows

Conclusion

Splitting our service configuration into separate files is an extremely useful pattern to use within your codebase and can make maintenance of your project a lot easier when it comes to knowing where to look for changes. It may not be worth it when setting up a fresh project, however if you notice your startup.cs start to become muddied I would recommend reaching for this pattern.

Questions? Say hello on twitter

originally published on taylorgoodall.me on 08/12/2020
What Does .NET Do?. C# From Scratch Part 1.3
By: Ken Bourke
Tags: Programming, Dotnet, Csharp, Learning To Code, Software Development

Welcome to another part of the series C# From Scratch, a course dedicated to teaching you everything you need to know to be productive with the C# programming language.

In the previous part of the series, we looked at the different versions of .NET that are available to use for our C# projects. That part of the series is available here.

In this part of the series, we’ll look at what .NET does for our application.

What Does .NET Do?

Your computer can’t execute the code you write in C# directly.

To actually get code to execute on your machine (or any machine for that matter), you need an additional piece of software that translates the instructions in your source code file into something that can be executed by the computer. For C#, this additional piece of software is .NET.

.NET can be broken down into two main parts. There is the Common Language Runtime, more commonly known as the CLR, and the Framework Class Library, known as the FCL.

The Common Language Runtime

The CLR is responsible for running your .NET application.

The CLR is the tool that executes your application — it starts your application, manages the memory that your application is using and translates the instructions in your source code into instructions that the processor can understand.

The Framework Class Library

The Framework Class Library is a library of code that is written and tested by other developers.

You can use the Framework Class Library to perform common tasks in your application without having to write the code yourself. Using software from the Framework Class Library, you can perform basic tasks like opening files, storing data in a database and, communicating over a network.

The SDK that you downloaded and installed on your machine contains the .NET Runtime, the Framework Class Library, and some additional tools to make developing .NET applications with C# easier.

What’s Next?

Now that we understand the parts of .NET and what .NET does for our application, let’s create our first application using a tool that was installed as with the .NET SDK — the .NET Command Line Interface.
I created Pac-Man in C#/.NET Console
By: Fabio Stein
Tags: Game Development, Coding, Dotnet, Technology, Csharp

Scene

Now with a working base for rendering and controls it was time to define the game map with the player, objects and ghosts. I decided that the map should be easily edited and with that in mind I implemented a Scene class that was responsible for loading a .txt map file and store the game state with the current 2d grid state, positions and entities.

Game Constants

After defining some game constants, our base map.txt looks like this:

?????????????????????

?...?...........?...?

?.?.?.?.?????.?.?.?.?

?.?...?...?...?...?.?

???.?????.?.?????.???

?.?...?.......?...?.?

?.?.?.?.?? ??.?.?.?.?

?...?...?@@@?...?...?

?.?.?.?.?????.?.?.?.?

?.?...?.......?...?.?

???.?????.?.?????.???

?.?...?...?...?...?.?

?.?.?.?.?????.?.?.?.?

?...?.....C.....?...?

?????????????????????

Of course, some implementations were still missing, like game fruits and other logic, but for this step it was going good enough.

So, for now the logic was still basic, load the text file and set each position of our grid (2d array) to the respective character in the text, then it’s time to implement something a little bit more complex. Let’s think about the game movements focusing on three objects, the player, score and ghost, when the player moves towards a score position, after he exits that position what character are we going to set in that position? It might look obvious, an empty space, for this case it works but what if the ghost is moving towards a score position and after it leaves that position? A general approach wouldn’t solve this, instead we need to store which object was in that position before, then we will create some ‘layers’ in each position and with that we can have a ordered list / sequence of objects that are in the same position and we’ll display only the top layer of each position and when anything moves we just move that top layer position in front of another position and automatically the previous position will display the correct character.

For this logic the LinkedList is the perfect choice to these ‘layers’ approach, I’ll not write about this data structure in this post but I strongly recommend that you read about if you’re not familiar with it.

Then our 2d char grid became a grid of LinkedLists and I created a base class (EntityBase) for every entity in the map, then the map loading sequence was the following:
Rockstar feat. Source Code Generators
By: Rafael Oliveira
Tags: Rockstar, Dotnet Core, Dotnet, C Sharp Programming, Csharp

Rockstar feat. Source Code Generators

I recently watched a really interesting video from Dylan Beattie on the NDC called The Art of Code, where he talks about code that has no practical reason to exist except because it is fun, or beautiful, to write it. If you haven’t watched it, I seriously recommend it — it’s interesting and fun!

Towards the end of his talk, he introduces us to his own programming language. He created it in a bar and it’s since become famous worldwide: Rockstar.

While watching the talk, I remembered that I’ve been wanting to get started with source-code generators since the release of NET5.0 for another side project of mine, and what better than using Rockstar as a way to get started?

Introducing, the Rockstar Source Code Generator

Source-code generators are a new C# compiler feature recently introduced by Microsoft that lets developers inspect user code as part of the code compilation, and generate new C# source files that are added to the compilation. This is done via a new kind of code component that is called a Source Generator, that is added as an analyzer to any existing project. You use a generator in your project by either referencing a generator project or by adding it as a NuGet package. With that in mind, let’s start building our Rockstar to C# generator!

99 bottles of beer in Rockstar

I wanted the generator to allow me to embed Rockstar code in any existing C# project, and allow me to call it from normal C# code. So a natural place to “hide” such code is within comments. This way we can hide something as innocents as this comment on the left in our normal C# code-base.

As we don’t want to parse every single comment in our source-code as Rockstar code, let’s start by defining a suitable header format for identifying our code and giving a name to the class that will hold the generated code. Something appropriate as Let’s rock with (class name), to keep with the spirits.

Now to implementing the code generator. We start by importing a few NuGet packages as suggested on the official samples, and proceed to implement the ISourceGenerator interface and tag your generator with the [Generator] attribute:

The next step is to capture all comments from the input source-code syntax tree. A few google searches and I ended up in a familiar blog — familiar because Dan is a colleague of mine at Curiosity. A few laughs later, and after reading his post, code and playing with the Roslyn API, I’m happy to see that the API now provides an easy to use enumerator over all trivia in the parsed syntax tree, with the method DescendantTrivia() — this makes it easy to achieve what I need with a simple for loop:

We can use a simple regex to detect the right comment markers and extract both the class name and the source-code within the comment, and we are ready to go to the next step: transpiling Rockstar to C#, so we can inject it back into the compilation process using our generator.
A Fábrica de Arquitetos VII - Mediator Pattern + MediatR
By: Lucas Eschechola
Tags: Dotnet, Design Patterns, Software Architecture, Mediator, Mediatr

Welcome, my name is Lucas and i’m 20 years old and i’m .Net Developer over 5 years ago. Let’s Code!
Understanding .NET. C# From Scratch Part 1.2
By: Ken Bourke
Tags: Programming, Dotnet, Csharp, Learning To Code, Software Development

Welcome to another part of the series C# From Scratch, a course dedicated to teaching you everything you need to know to be productive with the C# programming language.

In the previous part of the series, we installed the tools which we will be using to create and run C# applications. They were .NET and Visual Studio Code. If you missed that part of the series, you can find it here.

In this part of the series, we’ll take a step back to understand what we’ve just installed on our machine — what exactly is .NET?

Understanding .NET

Throughout this course, we will be writing software using the C# programming language. This software is written in human-readable instructions in a text file.

However, a computer can’t read this software and directly execute the instructions. So how can we get our software to execute on a computer?

For C#, there are two steps involved in getting our code to execute on a machine.

First, our C# source code is compiled into instructions that are understood by a tool called the CLR (Common Language Runtime). The result of this compilation is an executable program.

Second, when we execute our program, the CLR translates the instructions in the executable file into machine code that the computer understands and the instructions are executed on the machine.

The C# compiler and the CLR are part of the .NET SDK which you have just installed on your machine.

Different .NETs

There are two different .NET Frameworks available to use for developing software with the C# programming language: .NET and the .NET Framework.

The .NET Framework is a version of .NET that can only be used to write software for Windows machines. This version of .NET has been around since 2001 and is built and maintained by Microsoft.

.NET (also known as .NET Core) is a newer .NET that can be used to create applications that run on various platforms including Mac, Linux, and Windows. This version of .NET is completely open-source and community developed.

In this course, we’ll be using .NET.

If you are starting a new project and you can use .NET, then you probably should.

In some very specific cases, you might have to use the older .NET Framework for example, if there is a feature that you need to use which is only available in the .NET Framework.

What’s Next?

In this part of the series, we learned about the different versions of .NET that are available to build our C# applications with.

In the next part of the series, we’ll take a closer look at what exactly is in .NET and how it is used to create and run C# applications.
What is Blazor?
By: Vinh Pham
Tags: Web Framework, C Sharp Programming, Blazor, Dotnet

Blazor

Blazor uses C# and .NET but don’t panic, Blazor doesn’t require the browsers to have add-ons and plugins to run it. It uses WebAssembly. So, let’s get this straight. Blazor is a new web framework based on familiar web technologies like HTML and CSS but then allows you to use C# and Razor syntax instead of JavaScript. Blazor (Browser + Razor) enables developers to build interactive and reusable web UI for client-side applications written in .NET. With both client and server code written in C#, it allows you to share code and libraries, providing a platform to enable the development of vibrant, contemporary single-page application (SPA) platforms while using .NET end-to-end.

That sounds great. But how is it compared to other web frameworks and libraries?

While Blazor is still giving its first steps, it has proved that it is willing to keep improving and hearing the community. Some reasons why you should use Blazor include:

Its .NET-based nature, which brings the object-oriented power characteristic of C# language

Its server-side rendering (the prerendering) feature, which can highly scale the app’s performance

Its fast build time along with live reloading capabilities

The ability to work asynchronously in no time and small efforts

Conclusion

When compared to Blazor, other web framework and libraries stand out in some important ways. For example, if you’re a frontend developer, and have never been in touch with backend languages or .NET, going to Blazor can be tricky, since you’d have to learn C#, .NET, and Razor.

But I still think Blazor will have a bright and promising future ahead. I will get started to learn and understand more about it soon.
Securing .NET 5 Microservices with IdentityServer4 with OAuth2, OpenID Connect and Ocelot Api Gateway
By: Mehmet Özkaya
Tags: Microservices, Identity Server, Dotnet, Openid Connect, Oauth2

I have just published a new course — “Securing .NET 5 Microservices with IdentityServer4 with OAuth2, OpenID Connect and Ocelot Api Gateway”

In the course, we are securing .Net 5 microservices with using standalone Identity Server 4 and backing with Ocelot API Gateway. We’re going to protect our ASP.NET Web MVC and API applications with using OAuth 2 and OpenID Connect in IdentityServer4. Securing your web application and API with tokens, working with claims, authentication and authorization middlewares and applying policies, and so on.

Through 76 lectures and 5.5 hours worth of HD-quality content, you’re going to journey through some of the deepest depths of the security in microservices — experiencing all the development steps of run-aspnet-identityserver4 repository on github.

As a token of my appreciation for your support, I will also be offering a LIMITED BEST PRICE OFF DISCOUNT FOR YOU at the launch. This offer EXPIRES IN 5 DAYS.

USE BELOW LINK :

https://www.udemy.com/course/secure-net-microservices-with-identityserver4-oauth2openid/?couponCode=0F36E47863276913A687

This course will led you get started securing your ASP.NET based microservices applications with IdentityServer4 using OAuth 2 and OpenID Connect on distributed microservices architecture. And Also you’ll learn how to secure protected APIs backing with Ocelot API Gateway in a microservices architecture.

In the last section, we will give an assignment for security operations with identity server integration for an existing microservices reference application. We had developed run-aspnetcore-microservices reference application before this course. We will extend this application with IdentityServer OAuth 2.0 and OpenId Connect features with adding new Identity Server Microservice.

By the end of this course, you will have a practical understanding of how to secure .Net 5 Microservices with IdentityServer4 using OAuth2, OpenID Connect and Ocelot Api Gateway.

Below some useful links;

Check the Code on Github -> https://github.com/aspnetrun/run-aspnet-identityserver4

Check Explanation of this Microservices Repository on Medium -> https://medium.com/aspnetrun/securing-microservices-with-identityserver4-with-oauth2-and-openid-connect-fronted-by-ocelot-api-49ea44a0cf9e
F# Compiler Messages
By: Brett Rowberry
Tags: Programming, Open Source Software, Compilers, Dotnet, Fsharp

Backstory

I was reviewing some code at work recently and I noticed that one of our F# project files was ignoring a few warnings, but I didn’t know what they were. It looked something like this:

F# project file ignoring FS0025

Now imagine we had a code file like this:

F# implementation file with incomplete pattern match

The F# compiler normally yields a warning when it finds an incomplete pattern (not all cases are covered). However, because of the <NoWarn>0025</NoWarn> node in the project file, the build output does not include the warning:

Build succeeded.

0 Warning(s)

0 Error(s)

Without the <NoWarn> node, the build output is:

/somepath/FsAdvent2020.fs(8,11): warning FS0025: Incomplete pattern matches on this expression. For example, the value 'Hot' may indicate a case not covered by the pattern(s). [/somepath/FsAdvent2020.fsproj]

1 Warning(s)

0 Error(s)

Now, how would an F# developer know what FS0025 is? Well, they’re in luck …sort of. If they visit the F# compiler messages page, they’ll see a list of compiler messages. However, it’s far from complete. At the time of this writing, the table of contents looks like this:
Installing the Required Tools
By: Ken Bourke
Tags: Programming, Dotnet, Csharp, Software Engineering, Software Development

In this part of C# From Scratch, we’ll install the tools that are required to write programs in C# and run them on our machine.

Install the .NET SDK

When we write applications with C#, we use the language on top or a framework and runtime known as .NET.

To follow along with this course, you will need to download and install the .NET SDK (Software Development Kit). This kit contains the tools that your computer needs to convert a file containing C# source code into a program that can run on a computer.

You can download the latest .NET SDK on Microsoft’s .NET Downloads page.

On this page, select the correct operating system for your machine and download the latest version of the .NET SDK.

In the next part of the course, we’ll talk about the difference between the various versions of .NET.
Up and Running with .NET Core. C# From Scratch Part 1.0
By: Ken Bourke
Tags: Programming, Dotnet, Csharp, Software Engineering, Software Development

C# From Scratch is a series that teaches you how to program effectively using the C# language.

A very important part of learning a programming language is writing code. That’s why throughout the course there are demos that you should follow along with and programming challenges for you to work through independently.

Aside from this prescribed programming, you should be experimenting with the code that we create. One of the best ways to test if you understand code is to change it to produce the desired outcome.

Throughout the course, we’ll be making a console application that lets a user record the results of a race and compute some statistics around those results.

After the course, you will be able to create your own applications to solve problems using the C# language.

To follow along with this course or to create your own C# applications, you will need to install some tools on your machine.

This module, Up and Running with .NET Core, shows you which tools to install and gives an introduction to how they work.
DotVVM Advent Calendar 2020
By: Daniel Gomez Jaramillo
Tags: Dotnet Core, Dotnet, Aspnetcore, Web Development, Csharp

Hello everyone! Welcome to DotVVM Advent Calendar 2020, 25 days with 25 amazing articles to learn about DotVVM and the multiple applications we can carry out. We have an article for each of the advent days with the following general themes:

Basics of ASP.NET with DotVVM.

Controls for web forms.

Data reporting.

Web pages with SQL and NoSQL databases.

Deploying dotVVM applications to Azure and Amazon Web Services

Construction of applications for real life.

Calendar

The main idea of this initiative in its first edition is that among all we can learn from the basics to the most advanced about the wonderful world of web application development with ASP.NET and DotVVM through the contributions generated by the DotVVM community this year.

Dec 1st: Introduction to DotVVM.

Dec 2nd: Setting up for Dotvvm Development on Linux, MacOS and Windows.

Dec 3rd: DotVVM and ASP.NET Core: Implementing CRUD operations.

Dec 4th: Working with ASP.NET Core and DotVVM on Visual Studio Code.

Dec 5th: Web forms with DotVVM controls.

Dec 6th: DotVVM:Build Conditional Validation Attribute.

Dec 7th: Reports in DotVVM with GridView, CheckBox, and TextBox controls.

Dec 8th: DotVVM Controls : GridView.

Dec 9th: Web forms with DotVVM Business Pack.

Dec 10th: DotVVM: upload files using FileUpload control.

Dec 11th: Star rating with DotVVM and CSS.

Dec 12th: DotVVM: Add shortcuts to your buttons and links.

Dec 13th: Developing web applications with ASP.NET Core, DotVVM and MongoDB.

Dec 14th: DotVVM CRUD application with Entity Framework and Cosmos DB.

Dec 15th: Working with web services through ASP.NET Core and DotVVM (A step by step guide)..

Dec 16th: Deploy DotVVM and .NET Core web applications to Azure (Everything you need to know)..

Dec 17th: GitHub Actions + Azure: Continuous deployment of ASP.NET Core with DotVVM applications.

Dec 18th: Working with WCF Services through ASP.NET and DotVVM (A step-by-step guide)..

Dec 19th: DotVVM Authorization with IdentityServer4.

Dec 20th: Deploying ASP.NET Core and DotVVM web applications to a virtual machine in Azure

Dec 21st: DotVVM CRUD application with Cloud Firestore.

Dec 22nd: Deploy web applications with ASP.NET Core and DotVVM on AWS Elastic Beanstalk.

Dec 23rd: Containerize a Dotvvm Web Application and a MySql Database with Docker Compose.

Dec 24th: Build Azure Pipeline to your DotVVM application.

Dec 25th: Building a Dashboard with ASP.NET Core and DotVVM.

We hope you enjoy and learn about DotVVM during these 25 days of advent. If you have any questions or would like to receive any feedback, you can write to me on Twitter or request information from info@dotvvm.com. If you want to share your progress with this amazing experience, you can use the hashtags #DotVVMCommunity #DotVVMAdventCalendar :)

From now on, ¡Merry Christmas!
Introduction and Index
By: Ken Bourke
Tags: Programming, Dotnet, C Sharp Programming, Learning, Software Development

C# From Scratch is a series dedicated to teaching you how to create applications using the C# programming language.

By the end of the series, you will have all of the knowledge that you need to be productive with C#.

Why Learn C#?

C# is a general-purpose language that was originally designed by Microsoft to be used for developing apps on the Microsoft platform. It is the language of choice to build apps for the Microsoft platform since it is a well-designed and high-level language.

With the introduction of the .NET Core framework, C# can now be used to develop cross-platform apps. C# is also the recommended language to use when making games through the Unity Game engine.

Why Learn C# with C# From Scratch?

This series is written with beginners in mind.

The course takes a slow approach to explain new concepts and each part builds on the previous one. By the end of the series, you will know enough about the C# language and the .NET framework to build your own applications with C#.

This course uses a practical, hands-on approach to teaching you C#. Throughout the series, we will be developing a command-line application that records race results.

In each part of the series, you’ll put your new knowledge to use by building a part of the application.

You won’t only learn about the C# language, you will also learn about related, essential topics like error handling, object-oriented programming, and best practices for writing applications in C#.

Prerequisites

This is series is an introduction to C# for beginner programmers. It is not an introduction to programming itself.

To get the most value out of the series, you should already have an understanding of basic programming concepts such as loops and boolean logic.

Parts in the Series

Here you can find the complete list of published parts in the C# From Scratch series. This section is updated every time a new part of the series is released.

Up and Running with .NET Core

Introduction

Installing the Required Tools

Understanding .NET

What Does .NET Do?

Hello, World

Working with the .NET CLI

Creating a New .NET Project

Running a .NET Project

Working with Visual Studio Code

A Dynamic Application

Understanding Program.cs

Making it Interactive

Debugging the Application

Unhandled Exception Messages

Using the Debugger
.Net 5 Geçiş Süreci
By: Ethem Boynukara
Tags: Dotnet 5, Yazılım Geliştirme, Net5, Dotnet, Dotnet Core

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
How to fix local debugging of Azure Functions in Visual Studio for Mac
By: Rob Wilson
Tags: Azure Functions, Dotnet, Azure, Dotnet Core

Visual Studio 8.8.4 fixes BigSur CLR error

UPDATED — 14th January 2021

The bug has now been closed as fixed by Visual Studio — please ensure you have the latest version installed.

UPDATED — installed Big Sur? First ensure that you have updated Visual Studio to version 8.8 release 4 (Wednesday 16th December 2020).

This will resolve an issue where the terminal doesn’t display the Azure function output, instead you would have been greeted with a CLR error.

The rest of this blog covers how I could get Visual Studio working by rolling back the version of Xcode (this worked before I upgraded to BigSur).

Today I tried to run my Visual Studio Azure Function on a Mac, but instead of the terminal showing the Azure function output it displayed nothing.

A very unexciting terminal screenshot

The root cause appears to be related to this bug https://github.com/dotnet/runtime/pull/42900

Oddly Xcode 12 and .NET 5 don’t play well together. The following issue was raised https://github.com/dotnet/runtime/issues/42311 and this comment from c-lamon solved the terminal issue for me.

The solution that worked for me!

I don’t quite understand how Visual Studio for Mac, .NET 5 and Xcode are dependent on each other, but the action of reverting to Xcode 11 does work 🥳

In summary download XCode 11.7 from Apple, rename it (so you can keep Xcode 12.x running too) and move the renamed file to your Applications folder and then tell the operating system which version of XCode should be used.

sudo xcode-select -s /Applications/Xcode_11.app ← To fix Visual Studio on Mac

or

sudo xcode-select -s /Applications/Xcode.app ← Use the latest XCode

Xcode-select controls the location of the developer directory used by xcrun, xcodebuild, cc and other Xcode and BSD development tools.

xcode-select man page extract

And voila — Azure functions are now successfully running locally on the Mac through the Visual Studio debugger.

My only disappointment was that the terminal didn’t render the Microsoft Azure Functions ASCII art 😏

Azure Functions Logo — not included

Follow me on Twitter - https://twitter.com/codingrob
C# 9.0 İle Gelen Yenilikler
By: Mert Şen Findicak
Tags: Dotnet Core, Dotnet, Csharp, C Sharp Programming, Software Development

Learn more. Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Make Medium yours. Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore
Laravel like log viewer for SeriLog (Asp.NET MVC)
By: Muthukumar Thevar
Tags: Logging, Aspnet, Dotnet, Serilog, Laravel

Well, there are a lot of options out there to view the generated logs by the SeriLog. Most(90%) of them are cloud and paid services.

Professionally being a .net developer, I too work on many other languages like PHP, NodeJs, React, etc.

In one of my projects, I had to use the laravel framework which was very new for me. I read some documentation and started off my setup and coding with the laravel framework.

I had to configure logs in the application so I stumbled upon this log viewer https://github.com/rap2hpoutre/laravel-log-viewer which was very easy to configure and I found it very reliable and handy.

I loved the UI and the way it shows the logs and all which inspired me to make this similar log viewer for asp.net MVC.

So I head on to copy the source code
Many-To-Many in EF .NET 5. .NET Conf 2020 was happening this week…
By: Patrick Ullrich
Tags: Dotnet 5, Entity Framework Core, Many To Many, Dotnet, Entity Framework

Let me introduce the data model we will be using for this post. It’s a straight forward relationship between Streamers and Subscribers. A streamer can have many subscribers and a subscriber can subscribe to many Streamers. They are linked via a Junction Table that we will call Subscriptions.

Data Model

I will only show some highlights in this post. You can find some more complete code here on GitHub.

Without further ado, let’s look at the old way to implement Many-To-Many.

As we can see the Streamer has a List of Subscriptions (and so does the Subscriber). This means if we want to get all Subscribers of a Streamer we need to navigate through the Subscription Entity every time.

For example, if we are looking for Streamers that have Subscribers above the age of 18 we would use the following query:

context.Streamers.Where(streamer => streamer.Subscriptions.Any(sub => sub.Subscriber.Age > 18)).ToList();

Yes, in our Database we do expect to have a Junction Table, but it currently has no additional purpose but to connect our two entities. Wouldn’t it be way better, if we could simply navigate from Streamers to Subscribers?

Incomes EF .NET 5 with even better Many-to-Many support.

We are now able to go directly from our Streamer entity to our Subscriber entity. First, let’s add a reference between the 2 entities.

public class Subscriber

{

...

public ICollection<Streamer> Streamers { get; set; }

} public class Streamer

{

...

public ICollection<Subscriber> Subscribers { get; set; }

}

This allows us to simplify the query:

context.Streamers.Where(streamer => streamer.Subscribers.Any(sub => sub.Age > 18)).ToList();

Awesome, but wait - what if we need more information on our Junction Table? Let’s say, we want to track how many months a Subscriber has been Subscribed.
.NET Framework vs .NET Core: What is the Difference and the Future of .NET
By: Todor Vasilev
Tags: Net Core, Dotnet Framework, Dotnet, Dotnet Core

Microsoft has been rapidly developing and releasing new technologies during the past years. When I started programming in 2015, .NET Core was just announced, and the primary software framework of Microsoft was the .NET Framework. .NET Core has come to the market as a modern solution to addresses the limitations of the traditional .NET Framework and has earned much popularity since it was released.

Developing complex business applications, primarily for financial services companies, I have worked with both the .NET and .NET Core frameworks. Thus, in this article, I share my experience and focus on the comparison between the two .NET frameworks. I walk you through some .NET basics, give some examples from my daily projects, as well as what to keep eyes on.

.NET Framework Ecosystem

Before looking at the two frameworks, let’s start with some high-level picture of the .NET Ecosystem. It has three major components: .NET Framework, .NET Core and Xamarin, as it can be seen on the figure below.

Xamarin is used for building cross-platform mobile applications. It targets iOS, Android or Windows Phone devices. It is not a subject of this article because if the solution you develop is a mobile application, Xamarin is currently the only choice.

.Net Framework is the first software framework introduced by Microsoft ,back in 2000. It includes a runtime environment for creating Windows apps and web services and supports websites, services, and desktops apps. It has been in use for already 20 years. which proves its reliability, also backed up by the many tools and libraries developed for it.

.Net Core was introduced in 2016 as an open-source and cross-platform framework. It is used for building applications for all operating systems, including Windows, Mac, and Linux. .Net Core supports multiple languages — C#, Visual Basic, and F#. The focus when creating the framework was on the highly-performing and scalable systems. It is also optimized for developing microservices.

Read the whole article to learn when to use .NET vs. NET Core, as well as, to discover more about the future of .NET — .NET 5.
Coherence Client for .NET Core Released
By: Aleks Seovic
Tags: Announcements, News, Dotnet, Coherence, Dotnet Core

We are pleased to announce that Coherence Client for .NET Core 3.1 and .NET Standard 2.0 has been released, and is available for download from NuGet.org.

This allows .NET Core applications to access data managed in Coherence from Windows, Linux and OS X.

Apart from the assembly name, which is now Coherence.Core , this client is API-compatible with the existing Coherence Client for .NET Framework 4.0 (or newer), which should make transition from .NET Framework to .NET Core as simple as changing the assembly reference and recompiling the application against .NET Core SDK.

Some of the features that are .NET Framework-specific, such as legacy ASP.NET session store support, as well as support for Windows Forms and WPF, have been removed from this release.

What’s Next?

While we are very glad that Coherence users now have a way to access Coherence from .NET Core applications running on platforms other than Windows, this is by no means our only goal when it comes to .NET support.

We are currently working on the next generation .NET client for Coherence, which will support both Coherence*Extend and our new, gRPC-based transport layer, and will add a number of features that have been requested by the users, such as:

Support for generics throughout the API

LINQ and Entity Framework support

ASP.NET Core support

We are still in the very early stages, so it will take some time until that new .NET client is generally available, but you can follow our progress on GitHub (make sure to “star” and/or “watch” the project to be notified when the milestone releases are published), and influence our direction by requesting the features that you feel are missing and would be nice additions to Coherence Client for .NET.

In the meantime, give our .NET Core client a try and let us know if you run into any problems by reporting bugs on GitHub.
Performance Boost in .NET 5. .NET 5, released on November 10, is not…
By: Yury Fedorov
Tags: Net5, Dotnet, Performance, Net Core 3, Dotnet Core

.NET 5, released on November 10, is not going to stay for a long: its support is expected to over on February 2021 (3 months after the release of .NET 6 next LTS). Still there is a very valid argument to evaluate seriously switching to .NET 5 from .NET Core 3.1 (current LTS): it is the performance.

Microsoft .NET team has done a huge job to improve performance of .NET 5. Here is a very good announcing article about it with many details of improvements written earlier this year by Stephen:

And now we can see and use it by ourselves in production:

Even for such basic operation as string interpolation my fork of performance benchmark shows improvement of 10%, comparing to .NET Core 3.1:

For less performant string formatting techniques the improvements are even more significant: ie. string.Format shows to be 23% faster.

Happy coding!
Azure AD B2C: Preventing duplicate emails with multiple identity providers
By: Luca Perico
Tags: Active Directory, Azure Active Directory, Dotnet, Azure Functions, Azure

Introduction

The goal of this tutorial is to show how to simply achieve unique emails across multiple identity providers when using Azure Active Directory B2C behind your application. And yes, I’m still struggling to understand why I need to write code to do that, instead of simply going to the Azure portal and click a checkbox, somewhere under the settings page.

Anyway, every developer loves writing code, so let’s move on :)

Overview

To achieve our goal, we will write some .NET code that uses Microsoft.Graph API to access the list of users present in our AD B2C. The API endpoint of interest for this tutorial is documented here.

Note: This tutorial doesn’t cover in detail how to configure the Active Directory and how to create a Service Principal, because this is widely described in many articles on the web.

Prerequisites