Rendering dynamics views in Razor (chtml), How to add a FileProvider to razor in asp.net core 3.0?

前端 未结 2 1759
执念已碎
执念已碎 2021-01-23 18:50

I am migrating from asp-net core 2.2 to asp-net core 3.0, I was using this block to define my File Class Provider, as you know this is used to create dynamic razor views (dynami

2条回答
  •  离开以前
    2021-01-23 19:08

    DavidG provided us the solution: (I have tested and it works).

    The solution is:

    services.AddControllersWithViews().AddRazorRuntimeCompilation(
        options => options.FileProviders.Add(new PhysicalFileProvider(appDirectory)));
    

    In this case:

    services.AddControllersWithViews().AddRazorRuntimeCompilation(
        options => options.FileProviders.Add(new MyCostumizedFileProvider()));
    

提交回复
热议问题