RoundTheCode Profile Banner
David Grace - Round The Code Profile
David Grace - Round The Code

@RoundTheCode

Followers
399
Following
89
Media
186
Statuses
744

.NET enthusiast 🚀 | Visit my website for .NET tutorials, code examples, and coding challenges 💻 | Teaching .NET through my YouTube channel 🎥

Worthing, United Kingdom
Joined April 2013
Don't wanna be here? Send us removal request.
@RoundTheCode
David Grace - Round The Code
1 year
To practice C#, you could turn on your computer and wait for Visual Studio to load. But wouldn't it be good to practice online? Check out my online code editor so you can practice your C# coding skills with this coding challenge to convert mph to kph. https://t.co/knkqRHuelp
0
0
2
@RoundTheCode
David Grace - Round The Code
1 year
You can call EnsureSuccessStatusCode in a HttpResponseMessage type when making an API call in your .NET project. With this line, if an unsuccessful status code is returned from the HTTP response, it will throw an exception.
1
0
1
@RoundTheCode
David Grace - Round The Code
1 year
Learn about adding SignalR to your ASP .NET Core project so you can add real-time communication. As well as sending and receiving messages, you'll also learn about how to send messages to different connected clients. Watch my video to find out more. https://t.co/Os1SQWrdW1
0
0
1
@RoundTheCode
David Grace - Round The Code
1 year
You can call multiple asynchronous jobs and await all of them to complete by using Task.WhenAll. Task.WhenAll will only be completed when all tasks specified in its parameters are completed.
0
0
1
@RoundTheCode
David Grace - Round The Code
1 year
Feature Management in ASP .NET Core allows you to add feature flags. You do it by adding the Microsoft.FeatureManagement.AspNetCore NuGet package and calling AddFeatureManagement extension method.
1
0
4
@RoundTheCode
David Grace - Round The Code
1 year
Learn about SignalR and how to send and receive a message back from a hub. Messages can be sent to all clients, or to particular clients. https://t.co/cfjRyJ9lw2
roundthecode.com
Learn how to add a SignalR hub to an ASP.NET Core app and how to connect to it by using a WebSocket through JavaScript.
0
0
2
@RoundTheCode
David Grace - Round The Code
1 year
You can use IConfiguration, IOptions or IOptionsSnapshot to get appsettings configuration values into an ASP .NET Core application. But which one should you use? Watch my video to find out.
0
0
0
@RoundTheCode
David Grace - Round The Code
1 year
When creating a custom scope in a .NET project, you can now create it asynchronously. The 'await' keyword has to appear before the 'using' statement, and you call the CreateAsyncScope.
0
1
1
@RoundTheCode
David Grace - Round The Code
1 year
To add the default extensions to wwwroot files in ASP .NET Core, you can add app.UseDefaultFiles() in Program.cs. This will add Default and Index (.htm and .html) as default files for a folder. It must be called before app.UseStaticFiles().
0
0
0
@RoundTheCode
David Grace - Round The Code
1 year
If you want to use IHttpClientFactory outside of ASP .NET Core, you can add Microsoft.Extensions.DependencyInjection and Microsoft.Extensions.Http to your project. Then build a service collection by adding your HttpClient to it.
0
0
0
@RoundTheCode
David Grace - Round The Code
1 year
In SignalR, you can use Clients.All to invoke a method to all connected clients. However, you can invoke a method to the connected client by using Clients.Client(Context.ConnectionId). This is handy if you want to send a message back after they sent one.
0
0
2
@RoundTheCode
David Grace - Round The Code
1 year
.NET 7 has now reached end-of-life meaning it's time to update! By not doing so risks your application's security. That's because Microsoft will no longer make any more updates to .NET 7 & won't put in fixes for newly found bugs. Watch my video for more: https://t.co/EnfzdVx9Gw
0
0
0
@RoundTheCode
David Grace - Round The Code
1 year
You can add custom middleware to your ASP .NET Core app by using app.Use. This example will add a response header of X-Frame-Options with a value of SAMEORIGIN. You can also add it in a class and register it by using app.UseMiddleware();
0
0
0
@RoundTheCode
David Grace - Round The Code
1 year
Have you tried using VS Code to develop a .NET application? Watch my video where we develop an Web API project and run it using Visual Studio Code. How does it compare to Visual Studio? https://t.co/XSnLxER5gi
0
0
0
@RoundTheCode
David Grace - Round The Code
1 year
You can use a scoped service in a .NET background task like a hosted service. Inject the IServiceProvider instance, and then call the CreateScope method within it. You can use that scope instance to resolve a scoped service.
0
0
0
@RoundTheCode
David Grace - Round The Code
1 year
Theory in xUnit allows you to add parameterised tests. You can add [InlineData] with [Theory] to your tests and add the parameters you wish to test against. This stops adding unit multiple tests for the same logic.
0
0
0
@RoundTheCode
David Grace - Round The Code
1 year
Useful .NET xUnit commands: Creates xUnit project: dotnet new xunit Adds NuGet package dotnet add package Moq Runs a test: dotnet test
0
0
0
@RoundTheCode
David Grace - Round The Code
1 year
Useful .NET commands: Creates new Web API project: dotnet new webapi -n MyProject -controllers Creates interface: dotnet new interface --name IMyService Creates class: dotnet new class --name MyService Creates API controller: dotnet new apicontroller --name MyController
0
0
0
@RoundTheCode
David Grace - Round The Code
1 year
If an unhandled exception is thrown in C#, it will always run the finally block if you are using ASP .NET Core. However if you are using a console app, the program will exit before calling the finally block meaning that it will never execute.
0
0
0
@RoundTheCode
David Grace - Round The Code
1 year
IOptionsSnapshot allows you to bind config values from appsettings into a class. You add the options in Program.cs and can inject IOptionsSnapshot adding the config class as the generic type. It has a scoped lifetime scope meaning values can change without restarting the app.
0
0
1