ASP.NET Core 1.0 on IIS error 502.5 – Error Code 0x80004005

I was able to fix it by running “C:\Program Files\dotnet\dotnet.exe” “C:\fullpath\PROJECT.dll” on the command prompt, which gave me a much more meaningful error: “The specified framework ‘Microsoft.NETCore.App’, version ‘1.0.1’ was not found. – Check application dependencies and target a framework version installed at: C:\Program Files\dotnet\shared\Microsoft.NETCore.App – The following versions are installed: 1.0.0 – Alternatively, install … Read more

.net Core Quartz Dependency Injection

You can use the Quartz.Spi.IJobFactory interface and implement it. The Quartz documentations states: When a trigger fires, the Job it is associated to is instantiated via the JobFactory configured on the Scheduler. The default JobFactory simply activates a new instance of the job class. You may want to create your own implementation of JobFactory to … Read more

Is there a built in way of using snake case as the naming policy for JSON in ASP.NET Core 3?

Just slight modification in pfx code to remove the dependency on Newtonsoft Json.Net. String extension method to convert the given string to SnakeCase. public static class StringUtils { public static string ToSnakeCase(this string str) { return string.Concat(str.Select((x, i) => i > 0 && char.IsUpper(x) ? “_” + x.ToString() : x.ToString())).ToLower(); } } Then in our … Read more

ASP.Net Core SAML authentication

This is probably basically an updated version of Anders Abel’s answer, but: I used They have a nuget package with 36k downloads called “Sustainsys.Saml2.AspNetCore2”. They have a helpful example .net core app using it that also uses .net core identity here: (take a look at their startup.cs and also their external login razor … Read more

How do I serve static files only to authorized users?

Yes, they should go in wwwroot. Currently there is no built-in way to secure wwwroot directories. But creating a middleware module to accomplish it is pretty straightforward. There is an easy to follow tutorial here. If you’re not familiar with developing middleware, I posted a GitHub project that shows how to create middleware in three … Read more

.NET Core dependency injection -> Get all implementations of an interface

It’s just a matter of registering all IRule implementations one by one; the Microsoft.Extensions.DependencyInjection (MS.DI) library can resolve it as an IEnumerable<T>. For instance: services.AddTransient<IRule, Rule1>(); services.AddTransient<IRule, Rule2>(); services.AddTransient<IRule, Rule3>(); services.AddTransient<IRule, Rule4>(); Consumer: public sealed class Consumer { private readonly IEnumerable<IRule> rules; public Consumer(IEnumerable<IRule> rules) { this.rules = rules; } } NOTE: The only collection … Read more

HttpContext in .net standard library

There’s a problem to your approach: .NET Standard is the most bare-bones implementation of .NET available, meaning that only basic features which are platform- and scenario-agnostic are implemented. HttpContext exists on both the .NET Framework and .NET Core (both of which implement .NET Standard, by the way), but being specific to the Web, it does … Read more

Error handling (Sending ex.Message to the client)

Here is an simple error DTO class public class ErrorDto { public int Code {get;set;} public string Message { get; set; } // other fields public override string ToString() { return JsonConvert.SerializeObject(this); } } And then using the ExceptionHandler middleware: app.UseExceptionHandler(errorApp => { errorApp.Run(async context => { context.Response.StatusCode = 500; // or another Status accordingly … Read more