0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【実践】Blazor/MudBlazorのBasePath(ベースパス)対応ガイド

Last updated at Posted at 2025-03-21

Blazorアプリをサブディレクトリにデプロイする際の BasePath(ベースパス) 対応について簡潔にまとめます。

🎯 BasePathとは?

アプリケーションがホストされる基準パスのことです。

例:

  • ルート: https://example.com/
  • サブディレクトリ: https://example.com/myapp/

🔧 appsettings.jsonにBasePathを記述

appsettings.jsonBasePath を設定しましょう。


🧩 App.razorでの <base> タグ設定

<base> タグに appsettingsで設定したBasePath を指定します。


⚠️ 開発ルール:相対パスで統一

アプリケーション内のナビゲーションやリンクは 相対パスで統一 しましょう。


🚩 よくあるトラブル回避

  • <base> の記述忘れに注意
  • BasePathの末尾に / を付けるようにする
  • 全コンポーネントで絶対パスを避ける

📚 参考リンク


📝 まとめ

  • appsettings.json に BasePath を設定する
  • <base> タグに適切に設定する
  • アプリ全体で相対パスを意識する

これでサブディレクトリ配下へのデプロイでも安全に動作します!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?