mailwal

.NET Drip for 2026-10-25

.NET Drip
A weekly dose of C# and .NET programming insights, tutorials, and community news delivered straight to your inbox.

You ask the model the same question twice. Your app makes two network calls and pays for two answers. Sometimes that is exactly what you want. Sometimes a cache is a better fit.

Microsoft.Extensions.AI lets you add distributed caching to an IChatClient pipeline.

Try It

This example uses Ollama and an in memory distributed cache. Add the packages:

dotnet add package Microsoft.Extensions.AI
dotnet add package Microsoft.Extensions.Caching.Memory
dotnet add package OllamaSharp

With Ollama running locally and the llama3.1 model available, try this in a .NET 10 console app:

using Microsoft.Extensions.AI;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using OllamaSharp;

var model = new OllamaApiClient(
    new Uri("http://localhost:11434"),
    "llama3.1");

IChatClient chatClient = new ChatClientBuilder(model)
    .UseDistributedCache(new MemoryDistributedCache(
        Options.Create(new MemoryDistributedCacheOptions())))
    .Build();

string[] prompts =
[
    "What is a .NET assembly?",
    "What is a .NET assembly?"
];

foreach (var prompt in prompts)
{
    var response = await chatClient.GetResponseAsync(prompt);
    Console.WriteLine(response.Text);
}

The second identical prompt can be served from the cache instead of asking the model again.

The Big Gotcha

The cache only helps when the request matches what was cached. A slightly different prompt, model configuration, or relevant chat history can mean a different answer.

Be careful with personalized prompts and private data. Don't let one user's cached response become another user's answer. For longer conversations, caching a prompt without its conversation context would be the wrong shortcut.

The sample uses memory, so entries disappear when the process stops and are not shared with other app instances. Use a real distributed cache when that is what your deployment needs.

When Not to Use It

Skip response caching when answers need to be fresh, the model uses randomness that matters to your experience, or user context makes safe cache keys difficult.

Key Takeaway

UseDistributedCache adds caching to an AI client pipeline. It can save repeated calls, but only when the request is genuinely reusable and the cache boundary respects user privacy.


Notable Links

FromCurl: curl to .NET 10

FromCurl turns a pasted curl command into .NET 10 Minimal API endpoints, HttpClient snippets, and xUnit tests right in your browser. This post shares a free, MIT-licensed way to scaffold HTTP clients, servers, and tests for prototyping or learning, with a reminder to review auth, validation, and HTTPS before production.

Aspire 13.6.0 Release

Microsoft ships Aspire 13.6 with a persistent SQLite-backed dashboard so your local runs stick around, coordinated .NET builds, sharper CLI workflows, and first party Java and Rust hosting that make building and debugging cloud-ready apps smoother. This post explains how these updates improve day to day development, details new Azure deployment options and VS Code tooling, and flags key breaking changes like automatic TLS for local MongoDB.

Windows 11’s WinUI just got basic features and less RAM hogging, after years oflosing apps to the web

Mayank Parmar digs into Windows App SDK 2.5 Experimental, where WinUI 3 finally gains native TableView and Chart controls plus a memory growth fix, closing a frustrating framework gap that pushed apps to Electron or WebView2. This post explains why these long-missing basics can make data heavy desktop apps feel truly native and less RAM hungry, even if everything is still experimental.

Ollama ASP.NET Core: Running Local LLMs (and Switching to OpenAI with OneSetting)

Rahmat Afridi lays out a clean pattern for running local LLMs with Ollama in ASP.NET Core and swapping to OpenAI via a single configuration setting while keeping business logic blissfully unaware. This post packages a slim IAIGateway, OpenAI-compatible HTTP calls, secure server-side options, and practical guardrails for tool calls, latency, and embedding compatibility so your RAG workflow stays reliable.

Uno Platform 6.7 Release Community Standup

Sam, Steve, and Martin unpack all the cool updates in the new Uno Platform 6.7 release, including new Android form factors, semantic styling, Skia rendering performance, WinUI parity, and more.

.NET MAUI Community Standup: Inside GnollHack: Cross-Platform Game Development with .NET MAUI

David Ortinau and Gerald Versluis welcome Tommi and Janne, the creators of GnollHack! GnollHack is a cross-platform, turn-based rogue-like built on the classic NetHack codebase and modernized with animated graphics, music, sound effects, voiceovers, and touch-friendly mobile gameplay.


Easier to read in your browser?

You can find this issue at https://dotnetdrip.com/archive/2026-10-25/.


Sponsored by Shortform
What the People Building AI Actually Read
The people building AI aren't only reading about AI. Sam Altman's pick for getting more done is [BOOK], and it has nothing to do with machine learning.
Shortform breaks down books like The Beginning of Infinity, Zero to One, and Thinking, Fast and Slow into the key ideas, the context behind them, and what to do with them.
Get the ideas behind the breakthroughs in about 15 minutes, then decide which ones deserve your whole weekend.
x-twitterdiscordyoutubetwitchexternal-link

This dropped into your inbox because you subscribed at dotnetdrip.com or one of Michael Jolley's other web properties.

Did this hurt your brain? You can stop receiving future .NET Drips by unsubscribing at any time.

PO Box 795, Odenville, AL 35120