Skip to content

Instantly share code, notes, and snippets.

View RickStrahl's full-sized avatar

Rick Strahl RickStrahl

View GitHub Profile
@RickStrahl
RickStrahl / MinimalApiAspNetStartup.cs
Last active October 11, 2021 02:21
Minimal API Startup in 6.0 for ASP.NET Core application - Auto-Refresh not working for Razor
using LicensingService.Configuration;
using Microsoft.AspNetCore.Authentication.Cookies;
using Newtonsoft.Json.Serialization;
using Westwind.Licensing;
using Westwind.Utilities.Data;
var builder = WebApplication.CreateBuilder(args);
var services = builder.Services;
var configuration = builder.Configuration;
var host = builder.Host;
@RickStrahl
RickStrahl / HttpClientPerfTestMinimal.cs
Created October 12, 2021 22:44
Simple test of HTTP Client under load with many simultaneous requests. For me this produces about 15000 requests in 20 seconds which is nearly on par with what the old HttpWebRequest client I used produced.
[TestClass]
public class HttpClientPerfTests
{
private string testUrl = "https://localhost:5001/api/artist/33";
private int counter = 0;
private bool cancel = false;
private HttpClient GetHttpClient(bool force = false)
{
if (!force && _httpClient != null) return _httpClient;
@RickStrahl
RickStrahl / program.cs
Last active November 7, 2021 05:47
ASP.NET Core Live Reload not working with this basic startup
using LicensingService.Configuration;
using Microsoft.AspNetCore.Authentication.Cookies;
using Newtonsoft.Json.Serialization;
using Westwind.AspNetCore.LiveReload;
using Westwind.Licensing;
using Westwind.Utilities.Data;
var builder = WebApplication.CreateBuilder(args);
var services = builder.Services;
var configuration = builder.Configuration;
@RickStrahl
RickStrahl / ApplicationInsightsUIIssues.md
Last active November 14, 2021 20:58
Application Insights Query Portal Issues

For ApplicationInsights in particular the UI is absolutely, horrendously terrible. I'm not a fan of Azure portal in general, but the ApplicationInsights portal in particular has a ton of UI issues that are not just cosmetic but functionally broken.

  • Startup shows a getting started video even on direct links to my query list or a specific query.

  • Can't jump directly to a query - always extra steps.

  • Creation of queries in the UI is confusing as hell
    Edit and Save are conflated in meaning. Save creates a new Snippet? WTF? But Ctrl-S saves? WTF?

@RickStrahl
RickStrahl / usingjint.md
Last active December 8, 2021 10:36
Using Jint to run JavaScript handlebars in C#
[TestMethod]
public void LoadHandleBarsTest()
{
    var engine = new Engine()
        // callback functions
        .SetValue("log", new Action<object>(Console.WriteLine))
        // set global values
        .SetValue("startValue", 10);
@RickStrahl
RickStrahl / SimpleHttpServer.cs
Created January 11, 2022 23:35
A simple .NET HttpListener implementation of a basic static Web Server on Windows
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Sockets;
using System.Net;
using System.IO;
using System.Threading;
namespace Westwind.Http.Server
{
@RickStrahl
RickStrahl / CreateGistFile.cs
Last active February 14, 2022 22:41
CreateGistFile
public static JObject CreateGistPostJson(GistItem gist)
{
dynamic obj = new JObject();
obj.Add("description", new JValue(gist.description));
obj.Add("public", gist.isPublic);
obj.Add("files", new JObject());
obj.files.Add(gist.filename, new JObject());
@RickStrahl
RickStrahl / UsingGistsForGeneralPurposeWebPagesWithMarkdown.md
Last active September 6, 2022 19:29
Using Gists for General Purpose Web Pages with Markdown
title abstract keywords categories weblogName postId
Using Gists for General Purpose Web Pages with Markdown
Most of you probably know and use Github Gists for sharing Code snippets. But did you know that Gists also support Markdown? Using Markdown makes it easy to create much richer code shareable code and even allows for an easy way to create self-contained Web content.
Gist,Markdown,Share,Social Media
Markdown
West Wind Web Log
502103

Using Gists for General Purpose Content with Markdown

@RickStrahl
RickStrahl / Markdig-MediaLinks-LocalFiles-Bug.cs
Created June 13, 2023 00:46
Demonstrates that Markdig Media links are not working when using relative links - appears they only work with http urls
@RickStrahl
RickStrahl / Fallbacks-log.txt
Created September 26, 2023 20:17
Fallback for app launching net7.0-windows with <RollForward>LatestMajor</RollForward> with net8.0 RC installed.
This file has been truncated, but you can view the full file.
Tracing enabled @ Tue Sep 26 20:10:54 2023 GMT
--- Invoked dotnet [version: 8.0.0-preview.7.23375.6, commit hash: 65b696cf5e7599ad68107138a1acb643d1cedd9d] main = {
C:\Program Files\dotnet\dotnet.exe
MarkdownMonster.dll
--roll-forward
LatestMajor
--roll-forward-to-prerelease
1
}
Reading fx resolver directory=[C:\Program Files\dotnet\host\fxr]