0

Visual Studio 2022 .NET Core 6.0.4 の環境で Blazor WebAssembly アプリを開発しようとしているのですが
プロジェクトを作成したテンプレートのままのアプリが IIS にデプロイすると
Loading... というメッセージが表示されたままで動作しません。

Visual Studio 上のデバッグモードではもちろん動作しますし、
IIS 上に作成したサイト直下にデプロイした場合も動作しますが
IIS 上のサイト配下のアプリケーションという形でデプロイすると上記の用な状態になります。

wwwroot の中の index.html の タグを書き換えれば動作するという情報を見て
"/" から "/BlazorApp_WebAssembly/" のようにアプリケーションを配置したパスに書き換えたのですが、
今度は以下のようなメッセージが表示されます。

An unhandled error ha occured. Reload

Chrome のデベロッパーツールで見てみると
以下のようなメッセージが出ていました。

------------------------------------------------------------------------------------------
blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Specified cast is not valid.
System.InvalidCastException: Specified cast is not valid.
   at Microsoft.AspNetCore.Components.Reflection.MemberAssignment.GetPropertiesIncludingInherited(Type , BindingFlags )+MoveNext()
   at Microsoft.AspNetCore.Components.ComponentFactory.CreateInitializer(Type )
   at Microsoft.AspNetCore.Components.ComponentFactory.PerformPropertyInjection(IServiceProvider , IComponent )
   at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider , Type )
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateComponent(Type )
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateChildComponentOnFrame(RenderTreeFrame& , Int32 )
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(DiffContext& , Int32 )
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& , Int32 )
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& , Int32 )
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& , Int32 , Int32 , Int32 , Int32 )
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer , RenderBatchBuilder , Int32 , ArrayRange`1 , ArrayRange`1 )
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder , RenderFragment , Exception& )
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry )
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
------------------------------------------------------------------------------------------
System.AggregateException: One or more errors occurred. (Specified cast is not valid.)
 ---> System.InvalidCastException: Specified cast is not valid.
   at Microsoft.AspNetCore.Components.Reflection.MemberAssignment.GetPropertiesIncludingInherited(Type , BindingFlags )+MoveNext()
   at Microsoft.AspNetCore.Components.ComponentFactory.CreateInitializer(Type )
   at Microsoft.AspNetCore.Components.ComponentFactory.PerformPropertyInjection(IServiceProvider , IComponent )
   at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider , Type )
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateComponent(Type )
   at Microsoft.AspNetCore.Components.RenderTree.WebRenderer.AddRootComponent(Type , String )
   at Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer.AddComponentAsync(Type , ParameterView , String )
   at Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHost.<>c.<<RunAsyncCore>b__15_1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHost.RunAsyncCore(CancellationToken , WebAssemblyCultureProvider )
   at Program.<Main>$(String[] args)
   --- End of inner exception stack trace ---
callEntryPoint @ blazor.webassembly.js:1
await in callEntryPoint (async)
At @ blazor.webassembly.js:1
await in At (async)
(anonymous) @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
------------------------------------------------------------------------------------------

いったい何が間違っているのでしょうか?
Blazor Server アプリは IIS のサイト配下のアプリケーションとして問題なく動作します。

0

この質問に回答するには、ログインする必要があります。

のタグが付いた他の質問を参照する。