LoginSignup
2
0

More than 1 year has passed since last update.

Blazor + Azure ActiveDirectory B2C認証時に'Cannot read property 'toLowerCase' of undefined' エラーが出る件

Posted at

事象

Blazor(WASM) + ASP.Netで作成したアプリをAzure AppSerivceにデプロイし認証をテストしたところ
'Cannot read property 'toLowerCase' of undefined' を吐き出しエラーが発生
ローカルPCでデバッガーで動作したところ問題なく動作

環境

.Net6 + VS2022 + AzureAD B2C

dotnet new blazorwasm -au IndividualB2C

にてテンプレートを作成しました
なお、.Net5でも同様のアプリを作成したことがあり、その時は動作しているので.Net6以降の問題だと思われます

現象

AppServiceにデプロイ後アプリを開きログインボタンを押すと
Authentication.razorの

@page "/authentication/{action}"
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication

<RemoteAuthenticatorView Action="@Action" /> <----このコントロール

@code{
    [Parameter] public string? Action { get; set; }
}

RemoteAuthenticatorViewが'Cannot read property 'toLowerCase' of undefined'
というエラーを吐いているところまで突き止めました。

対応策

ネットを見てみると同様のエラーで困っている人を発見
だが、Net 6 Preview 4とやや古い環境なので参考になるか?と思いつつ試してみたら治りました。

  1. Clientプロジェクト(*.csproj)に
    <ItemGroup>
        <TrimmerRootAssembly Include="Microsoft.Authentication.WebAssembly.Msal" />
    </ItemGroup>

を追加
2. Clientのbin、objフォルダを一度削除後、再ビルドしデプロイ

英語が得意ではないためなぜ?という部分が不明なのですが、対処療法として記述しました。

いずれ根本的な解決がなされることを期待しています

2
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
2
0