--- lang: ja-jp breaks: true --- # ASP.NET Core `Index.cshtml` が有るのに無いといってエラーになる。`InvalidOperationException: The view 'Index' was not found. The following locations were searched:` 2021-09-07 > aspnetcore/src/Security/samples/ClaimsTransformation/ > https://github.com/dotnet/aspnetcore/tree/main/src/Security/samples/ClaimsTransformation ![](https://i.imgur.com/VTDn9oh.png) ## 絶対にある!! ![](https://i.imgur.com/49fzXAv.png) ## `*.csproj` の `TargetFramework` を net6.0 → net5.0 に変更すると正常に動作した。。 ## `TargetFramework` を `net6.0` とする場合は以下のようにすると正常に動作した。 > 既存のプロジェクトでランタイム コンパイルを有効にする > https://docs.microsoft.com/ja-jp/aspnet/core/mvc/views/view-compilation #### `Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation`パッケージをインストール #### Startup.cs ```csharp= public class Startup { ・・・ public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews() .AddRazorRuntimeCompilation(); } ・・・ } ``` :::warning ただしこの場合、デバッグ実行するとシンボルの読み込みが行われて起動が遅い。。。 ![](https://i.imgur.com/oMS7gKM.png) ![](https://i.imgur.com/LrESHEJ.png) ::: ###### tags: `ASP.NET Core` `エラー`