BlazorWithRefit
Very simple demo of Blazor on wasm with Refit and System.Text.Json
Install / Use
/learn @richbryant/BlazorWithRefitREADME
BlazorWithRefit
Very simple demo of Blazor on wasm with Refit, Polly and System.Text.Json
Short Form -
Take a look in Program.cs, it contains pretty much everything you need. The Polly stuff is marked with a comment, feel free to remove it if you don't want Polly.
Longer version
This is an AspNetCore Hosted basic template, all I've done is swap out the direct call to WeatherForecastController with a service that uses Refit.
As you can see, it's a straightforward Refit service marked with a [Get] attribute.
public interface IWeatherService
{
[Get("/WeatherForecast")]
Task<WeatherForecast[]> GetForecasts();
}
Naturally, that's injected into FetchData.razor instead of the usual HttpClient.
All the setup for this is in program.cs as mentioned above, but in order to use System.Text.Json - which is the new default for AspNetCore - instead of Refit's preferred NewtonSoft.Json, you also need to override the default serializer. This is really simple. Just copy mine. You'll find it here. The setup for this is in the settings variable in program.cs. I could have inlined it but it's clearer this way.
Take what you need, go, enjoy cleaner RESTful Api calls from Blazor on wasm!
Related Skills
node-connect
354.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
112.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
354.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
354.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
