Skip to content

Instantly share code, notes, and snippets.

View antmdvs's full-sized avatar

Tony Davis antmdvs

View GitHub Profile
@davidfowl
davidfowl / DynamicController.cs
Last active October 9, 2023 12:30
Dynamically loading a controller
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.AspNetCore.Mvc.Infrastructure;
@davidfowl
davidfowl / Multitenancy.cs
Last active May 15, 2023 05:30
Multitenancy
using System;
using System.Collections.Generic;
using System.Threading;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
/*
- Don't need to support different services per tenant.
- Tenant services lifetime outlasts the request.
@damianh
damianh / AspNetCore use specific controllers
Created August 9, 2018 13:38
Configure aspnet core to use only specific controllers and not do assembly scanning. Also supports internal types.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.Extensions.DependencyInjection;
namespace MyApp
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using System.Threading;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
namespace header_propagation
@davidfowl
davidfowl / AUsage.cs
Last active September 17, 2023 10:26
Header propagation HttpClientFactory middleware
public void ConfigureServices(IServiceCollection services)
{
services.AddHttpClient("myclient");
// Global header propagation for any HttpClient that comes from HttpClientFactory
services.AddHeaderPropagation(options =>
{
options.HeaderNames.Add("Correlation-Id");
});
}