The best new features in .NET 6

Microsoft .NET 6 is the culmination of the .NET unification that started with .NET 5. Cross-platform .NET 6 merges the .NET Core, .NET Framework, and Xamarin/Mono technologies into a single .NET Framework, unifying the SDK and runtime for desktop, mobile, web, and cloud applications. Microsoft made .NET 6 generally available on November 9, 2021, alongside … Read more

.net – Intermittent Async SQLClient issue c#

I have this strange Intermittent Async SQLClient issue. We’ve recently migrated our .net core code from sync to async. I have an example of our code below. using (var con = new SqlConnection(_fimpConnectionString)) using (var cmd = new SqlCommand(“EMP2_GetPrositeDetails”, con) { CommandType = CommandType.StoredProcedure }) { cmd.Parameters.Add(new SqlParameter(“@SiteURL”, site.Host)); await con.OpenAsync(); using (var dr = … Read more

c# – Installing .NET packages for use in IIS web server (Windows Server 2019)

nor visual studio installed in the system. I don’t know how people before me worked on this server, Well, then that is most of your challenge. you do NOT mess around with trying to install this, and that, and more on the web server. What you do is get your hands on the source code … Read more

.net 5 – The entity type ‘IdentityUserLogin’ requires a primary key to be defined. If you intended to use a keyless entity type, call ‘HasNoKey’ in

I’m attempting to seed data for my API. I do have JWT authentication setup as well. I have to remove my original migration of the seeded data in order for the program to work. I found it would be helpful to already have data in the API when users interact with it. I”m just unsure … Read more

r – Error in tune grid in elastic net regression in tidymodels

I’m trying to tune a regularized regression, but the tune grid command returns several errors. I tried several grids, several recipes, but even using only one predictor, it still returns an error. Here’s a reproducible example df <- tibble(normalized_losses = c(NA, NA, NA, 164, 164, NA, 158, NA, 158, NA, 192, 192, 188, 188, NA, … Read more – .NET 6 – minimal web app for permanent redirect on Azure App Service on Linux

I have a subdomain which must redirect any route to a main domain root: http(s):// => http(s)://{*anything} => So, I have created a minimal .NET 6 web app: using System.Net; WebApplicationBuilder builder = WebApplication.CreateBuilder(args); builder.Services.AddHttpsRedirection(options => { options.RedirectStatusCode = (int)HttpStatusCode.PermanentRedirect; options.HttpsPort = 443; }); WebApplication app = builder.Build(); app.Urls.Add(“http://+”); app.Urls.Add(“https://+”); app.UseHttpsRedirection(); app.MapGet(“/”, () … Read more

Using the Decorator Pattern to Auto-Instrument .Net Classes With Otel Tracing | by Roni Dover | Jun, 2022

How decorators can help keep OpenTelemetry tracing instrumentation DRY Image by author .NET has definitely embraced OpenTelemetry in its recent releases. Its support for defining traces and spans using the built-in System. Diagnostics classes greatly simplify the task of instrumenting code. My only nitpicky complaint about the .NET implementation is the terminology confusion it manages … Read more

c# – Convert from HttpResponseMessage to IActionResult in .NET Core

This is much easier to accomplish in .NET v5 (erstwhile .NET Core v5). The ControllerBase class which is found in Microsoft.AspNetCore.Mvc.Core DLL contains scores of methods which return objects which inherit from IActionResult. IActionResult is the replacement for HttpResponseMessage. I ported below web API method which used to return a file. It was based on … Read more

.net core – Send SignalR message to a specific user

I have a Blazor wasm application that uses SignalR to send messages to clients. When sending message to all clients, everything works fine. In order to send messages to particular clients, I wanted to create a group for each client: public override async Task OnConnectedAsync() { //enter code here to keep track of connected clients … Read more