maui-aspire

Configures MAUI apps to connect to Aspire-hosted services with MSAL.NET authentication.

Updated Nov 27, 2025
One-click install
npx skills add https://github.com/seydakaratekeli/KamPay3 --skill maui-aspire-seydakaratekeli
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: maui-aspire
Source: https://github.com/seydakaratekeli/KamPay3/tree/main/KamPay/.github/skills/maui-aspire%20-%20Kopyala
Command: npx skills add https://github.com/seydakaratekeli/KamPay3 --skill maui-aspire-seydakaratekeli

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This guide helps mobile developers connect .NET MAUI applications to backend services hosted and orchestrated by .NET Aspire, resolving mismatches between AppHost service discovery and real device/simulator networking, and explaining how to authenticate MAUI clients using MSAL.NET public-client flows.

Core Features & Use Cases

  • Networking Guidance: Shows how to use real, network-reachable endpoints instead of Aspire service-discovery URIs and explains platform-specific loopback addresses for Android, iOS, Mac Catalyst, and Windows.
  • Authentication Pattern: Describes using MSAL.NET PublicClientApplication on MAUI to obtain access tokens and attach them to HttpClient requests via a DelegatingHandler for Entra ID protected Aspire APIs.
  • Development Workflow: Covers running Aspire AppHost alongside MAUI, using the Aspire dashboard to find API endpoints, emulator certificate handling and debug-time SSL workarounds, and .NET 10+ target TFM alignment.
  • Blazor Hybrid Consideration: Explains that authentication occurs at the MAUI layer (not inside the Blazor WebView) and how to expose auth state to Blazor components.

Quick Start

Configure my MAUI app to call the Aspire API using MSAL.NET public client, set the API base URL to 10.0.2.2:7001 for Android emulator and localhost for iOS simulator/mac, and attach bearer tokens via a DelegatingHandler on the typed HttpClient.

Frequently Asked Questions about maui-aspire

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I connect a MAUI app to an Aspire backend service?

To connect a MAUI app to an Aspire backend, configure HttpClient dependency injection with real network-reachable HTTPS endpoints instead of Aspire service-discovery URIs, adjusting for platform-specific loopback addresses like 10.0.2.2 for Android emulators.

What loopback address do I use for Android emulator when targeting Aspire APIs?

For Android emulator networking with Aspire APIs, use the 10.0.2.2 loopback address to map the emulator's localhost to the host machine, whereas iOS simulator and Mac Catalyst use localhost.

How do I authenticate a MAUI client against Entra ID protected Aspire APIs?

Authenticate a MAUI client against Entra ID Aspire APIs by using MSAL.NET PublicClientApplication to obtain access tokens and attaching them to HttpClient requests via a DelegatingHandler on the typed HttpClient.

Can I use Blazor Hybrid with MSAL.NET authentication in a MAUI app?

Yes, Blazor Hybrid can use MSAL.NET authentication by performing the sign-in at the MAUI layer rather than inside the Blazor WebView, exposing the authentication state to Blazor components for consumption.

Does .NET Aspire service discovery work directly with MAUI mobile devices?

No, .NET Aspire service discovery URIs do not work directly with MAUI mobile devices because emulators and physical devices require real network-reachable HTTPS endpoints and specific platform loopback addresses to communicate with the backend.

Why are my MAUI app's HTTPS requests failing on the Android emulator against Aspire?

MAUI app HTTPS requests against Aspire fail on Android emulators due to dev-certificate handling mismatches, requiring debug-time SSL workarounds and proper emulator loopback configuration using 10.0.2.2 to establish secure connections.