<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/blazor-auto-mode-pitfall-a0cokyksh" -->

---
title: Blazor Auto Mode PitFall | daily.dev
description: A common gotcha in Blazor Web App's Auto render mode is described: HttpClient calls inside OnInitializedAsync can fail with a 404 because the component...
canonical: https://daily.dev/posts/blazor-auto-mode-pitfall-a0cokyksh
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Blazor Auto Mode PitFall | daily.dev
og:description: A common gotcha in Blazor Web App's Auto render mode is described: HttpClient calls inside OnInitializedAsync can fail with a 404 because the component...
og:url: https://daily.dev/posts/blazor-auto-mode-pitfall-a0cokyksh
og:image: https://api.daily.dev/og/posts/A0coKyKSh.png
og:image:alt: Blazor Auto Mode PitFall
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Blazor Auto Mode PitFall

**[Advanced .NET](https://daily.dev/sources/advanceddotnet)** · [@ferouzkassim](https://daily.dev/ferouzkassim) · 2 min read · 0 upvotes · 0 comments

## Summary

A common gotcha in Blazor Web App's Auto render mode is described: HttpClient calls inside OnInitializedAsync can fail with a 404 because the component prerenders on the server first, where client-side base address resolution doesn't apply. Suggested fixes include configuring HttpClient.BaseAddress on both server and WASM client projects, deferring API calls to OnAfterRenderAsync with a firstRender check, guarding with OperatingSystem.IsBrowser(), and checking RendererInfo.IsInteractive before firing requests.

## Content

**Ever hit a 404 in Blazor Auto Mode even though your API endpoint is 100% correct?** 🐛

I ran into a tricky rendering bug yesterday while working with **Blazor Web App (Auto Render Mode)**. I had a component executing an HTTP call inside `OnInitializedAsync`. The URL looked perfectly valid, yet `HttpClient` kept throwing a **404 Not Found**.

**The Root Cause:** In Auto Mode, Blazor prerenders the component on the **Server** first before handing interactive execution over to **WebAssembly (WASM)** in the browser. During this initial prerender phase, `OnInitializedAsync` runs on the server host where the client-side base address or relative URI resolution doesn't match—leading to a failed request before the app even reaches the browser.

**How to Fix It:**

1. **Configure **`HttpClient.BaseAddress`** on Both Sides:** Ensure `Program.cs` in both the Server and Client WASM projects explicitly registers a valid base address.
2. **Defer Execution with **`OnAfterRenderAsync`**:** Move external API calls inside `if (firstRender)` in `OnAfterRenderAsync` so they only fire once the browser context is active.
3. **Guard with **`OperatingSystem.IsBrowser()`**:** Skip execution during server prerendering by checking the execution platform.
4. **Check **`RendererInfo.IsInteractive`**:** Conditionally execute or route your HTTP requests based on whether the component is currently running interactively.

Have you run into prerendering quirks with Blazor Auto Mode? How do you handle component initialization? 👇

![Gemini_Generated_Image_l6g2g0l6g2g0l6g2.jpeg](https://media.daily.dev/image/upload/s--HkdIZGrw--/f_auto/v1789812347/ugc/content_8a83bad2-ab4f-4e44-a6f5-a3f5ee6ca5ba?_a=BAMAMicg0)

## Similar posts on daily.dev

- [Blazor WASM vs Server vs Hybrid: Which Render Mode Should You Use?](https://daily.dev/posts/blazor-wasm-vs-server-vs-hybrid-which-render-mode-should-you-use--3qbqtfw1x) · Khalid Abuhakmeh · 2 upvotes · 0 comments
- [Blazor Basics: Common Blazor Mistakes Beginners Make \(and How to Avoid Them\)](https://daily.dev/posts/blazor-basics-common-blazor-mistakes-beginners-make-and-how-to-avoid-them--ewxy2lebp) · Telerik · 2 upvotes · 0 comments
- [Blazor Full Stack in .NET 10: When Should C\# Developers Use It?](https://daily.dev/posts/blazor-full-stack-in-net-10-when-should-c-developers-use-it--1jbibzfdi) · Syncfusion · 82 upvotes · 2 comments
- [Blazor Basics: SEO Basics for Blazor Web Applications](https://daily.dev/posts/blazor-basics-seo-basics-for-blazor-web-applications-slo0nqlyq) · Telerik · 0 upvotes · 0 comments

---

Tags: [#.net](https://daily.dev/tags/.net), [#webassembly](https://daily.dev/tags/webassembly), [#blazor](https://daily.dev/tags/blazor)

[View this post on daily.dev](https://daily.dev/posts/blazor-auto-mode-pitfall-a0cokyksh)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/blazor-auto-mode-pitfall-a0cokyksh","headline":"Blazor Auto Mode PitFall","text":"A common gotcha in Blazor Web App's Auto render mode is described: HttpClient calls inside OnInitializedAsync can fail with a 404 because the component prerenders on the server first, where client-side base address resolution doesn't apply. Suggested fixes include configuring HttpClient.BaseAddress on both server and WASM client projects, deferring API calls to OnAfterRenderAsync with a firstRender check, guarding with OperatingSystem.IsBrowser(), and checking RendererInfo.IsInteractive before firing requests.","url":"https://daily.dev/posts/blazor-auto-mode-pitfall-a0cokyksh","datePublished":"2026-09-24T17:49:40.171Z","dateModified":"2026-09-24T17:49:57.029Z","author":{"@type":"Person","name":"ferouz kassim kassim","url":"https://daily.dev/ferouzkassim","image":"https://lh3.googleusercontent.com/a/ACg8ocItJ5iUrcA92iX8uFQ4Rx6OJvhbj_UN-wE9erpXuQEumS1V9rqC=s96-c","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":180}},"interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/squads/advanceddotnet","name":"Advanced .NET"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Advanced .NET","item":"https://daily.dev/squads/advanceddotnet"},{"@type":"ListItem","position":3,"name":"Blazor Auto Mode PitFall"}]}
```

