X.509 certificates in .NET

Great summary: Eight tips for working with X.509 certificates in .NET – Paul Stovell.

Also found:

Advertisements

How to implement a formatter in Asp.Net Core

How to handle raw data in request body either manually or by registering a custom InputFormatter: Accepting Raw Request Body Content in ASP.NET Core API Controllers – Rick Strahl’s Web Log.

One big issue with automatic conversion between content body and an action parameter is how to handle too big content (in case of DOS for example). Reading any content body into a byte array could be very dangerous for server health in case of a large body.  This also prevents an always preferable handling using the streamed way.

Minidumper: cli to generate minidump

This cli tool is able to generate minidump of living app in three mode: full, minimal and heap. heap is really interesting because:

“dumps generated by the heap mode can be 5x or 10x smaller than full memory dumps, but will still allow complete investigation of many .NET issues by tools like Visual Studio and WinDbg (SOS)”

goldshtn/minidumper: Write minidumps of .NET processes with full memory, only CLR heaps, or no memory at all

Moreover, mini dump generation is located into an external library: DumpWriter. This library can be integrated into any program to add mini dump generation capability.

Generating a minidump is technically easy. You call MiniDumpWriteDump with a MINIDUMP_TYPE parameter to choose wich memory ranges to gather  or use a CallbackParam to manually filter memory ranges. But choosing the right one is a complicated process. Other posts are related on how memory ranges are choosen to be saved in heap mode :

Extension to Razor HtmlHelper

How to export a C# enum:

public enum AssetStatusEnum
{
    Free,
    Reserved,
    Inactive,
    UnderMaintenance
}

to

    var assetStatusEnum = {"Free":0,"Reserved":1,"Inactive":2,"UnderMaintenance":3}

In implementing an extension method:

public static class HtmlEnumExtensions
{
    public static MvcHtmlString EnumToString<T>(this HtmlHelper helper)
    {
        var values = Enum.GetValues(typeof(T)).Cast<int>();
        var enumDictionary = values.ToDictionary(value => Enum.GetName(typeof(T), value));
 
        return new MvcHtmlString(JsonConvert.SerializeObject(enumDictionary));
    }
}

and using it like this:

    var assetStatusEnum = @(Html.EnumToString())

 

Converting C# enums to JavaScript | Gunnar Peipman – Programming Blog