How to Solve “Could not create SSL/TLS secure channel” Error in .NET 4.6.x
Could not create SSL/TLS secure channel Recently, a legacy ASP.NET Web API application that we support started logging an exception and also giving back a HTTP 500 response on some of its API endpoints. The exception, or at least an inner exception within it, was: System.Net.WebException: The request was aborted: Could not create SSL/TLS secure […]
Using Serilog for Logging in ASP.NET Core
In .NET, there is built-in API that supports logging (Microsoft.Extensions.Logging) and there are many third-party logging providers that implement that API. For simple use cases, the built-in logging can be sufficient, but for many or our projects at Trailhead, we need a more powerful and flexible logging system. For these projects we often use a […]
Protecting Legacy .NET APIs with modern IdentityServer Tokens
Modern aspnetcore Web APIs are relatively easy to protect using Bearer Tokens issued by Duende IdentityServer. But there is a lot of legacy .NET framework code out there. This blog contains some simple tips to bring modern authentication to that world. Here is the big picture: This example starts with a legacy API written classic […]
Creating PDF Documents with Razor in ASP.NET Core 2.2 Web API
In this article, I will show you an easy way to create a PDF document and style it properly with Razor engine and the DinkToPdf library. The source code of this project can be found on GitHub. Setting up the project For simplicity, we will create a default Web API project with default options that […]
Breaking change in AspNetCore 2.2 for SignalR and CORS
To get authenticated SignalR hubs to work, you need to allow credentials in CORS, so your aspnetcore code might look like this: services.AddCors(action => action.AddPolicy(policyName, builder => builder .AllowAnyMethod() .AllowAnyHeader() .AllowAnyOrigin() .AllowCredentials())); As of 2.2. you can no longer combine AllowAnyOrigin and AllowCredentials! You will see a warning in the debug output: warn: Microsoft.AspNetCore.Cors.Infrastructure.CorsService[11] The […]
Solving “Could not create SSL/TLS secure channel” error in .NET 4.6.x
Could not create SSL/TLS secure channel Recently, a legacy ASP.NET Web API application that we support started logging an exception and also giving back a HTTP 500 response on some of its API endpoints. The exception, or at least an inner exception within it, was: System.Net.WebException: The request was aborted: Could not create SSL/TLS secure […]
AspNetCore – multi tenant tips and tricks
In two recent posts, I blogged about SignalR in .AspNet Core 2.1, and automating boilerplate multitenancy code in Entity Framework Core 2.1. Both these blogs alluded to knowing the identity of the calling user through claims and dependency injection. This blogs ties together those loose ends to show how that can be done. Authenticating the […]
Entity Framework Core 2.1 – Automate all that boring boiler plate!
In any real world enterprise application, you end up writing a lot of similar, tedious boilerplate code for bookkeeping . This logic results in a data model where each table is adorned with a lot of non-domain specific columns – does this look familiar? There are three common patterns at work here: Auditing – […]
Hello, ASP.NET Core 2.1
UPDATE, 2018 May 30: It’s alive. The dotnet team officially announces 2.1 on their blog! The newest version of ASP.NET Core will be released in just a few days, the team announced this week. They’re targeting Wednesday, May 30, 2018, with an early-access release available already. I’m excited about many of the new features in […]
SignalR as a service in Azure
In a previous post, I wrote about using SignalR in AspNetCore. Today, I tried the next step up – SignalR as a service! You will find the announcement here. This page has more details. So why would you want to run SignalR as a service, rather than embedding your Hubs in your API or Web […]
SignalR in AspNetCore
We’ve all been waiting for the first production release of SignalR for AspNetCore, and supposedly it’s going to be out there any day now. Impatient as I am, I started using 1.0.0-preview2-final – and it rocks! Here are some tips and tricks, including use of Dependency Injection and handling Multi Tenant scenarios. But first… a […]
A simple, generic Excel file exporter
I recently needed to write a routine that exports a query to an Excel file, and came up with a generic solution I thought might be helpful to share. The code is in an AspNetCore project, but the same principles would work in other .NET scenarios. Let’s start with the signature of the export method: […]
Is It Time to Update that ASP.NET Web Forms Project?
At Trailhead, we’ve recently been noticing an increase in a couple of questions from our clients. They are: 1. Is Web Forms dead?, and 2. Is ASP.NET still a good framework to use to build a new application? First off, there is some confusion about the difference between ASP.NET and Web Forms. They are not […]
Trailhead + ASP.NET Core 1.0
In this Edition Introducing ASP.NET Core 1.0 Trailhead’s Experience with .NET Core Our ASP.NET Core services: “ASP.NET Core” Online Training > Consulting Services > Introducing: ASP.NET Core 1.0 On June 27, Microsoft announced the official release of ASP.NET Core 1.0. Have you missed some of the twists and turns while the project was being developed? No problem, […]