我正在从 asp-net core 2.2 迁移到 asp-net core 3.0,我使用这个块来定义我的文件类提供程序,如你所知,它用于创建动态剃刀视图(动态 cshtml),我的问题是该段确实不行。
我已经实现了经典:
services.Configure<RazorViewEngineOptions>(opts =>
opts.FileProviders.Add(
new MyCostumizedFileProvider()
)
);
Run Code Online (Sandbox Code Playgroud)
在哪里:
MyCostumizedFileProvider:是文件提供程序的实现。
RazorViewEngineOptions:是在 aspnet core 2.0 中使用的 Razor 运行时编译器的处理程序。
在asp-net核心中我已经检查过
例如:
services.Configure<MvcRazorRuntimeCompilationOptions>(options => {
options.FileProviders.Clear();
options.FileProviders.Add(new MyCostumizedFileProvider());
});
Run Code Online (Sandbox Code Playgroud)
或者
services.Configure<MvcRazorRuntimeCompilationOptions>(options => {
options.FileProviders.Add(new MyCostumizedFileProvider());
});
Run Code Online (Sandbox Code Playgroud)
错误总是:
/Pages/Shared/ViewListPerson_1b2b2019-aad9-4096-a3b7-ece5dfe586c1.cshtml
at Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult.EnsureSuccessful(IEnumerable`1 originalLocations)
at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result)
at Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|29_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, …Run Code Online (Sandbox Code Playgroud)