https://cloud.tencent.com/developer/ask/59115
https://blog.csdn.net/megoodtoo/article/details/77160561
IRazorLightEngine engine = EngineFactory.CreatePhysical("Path-to-your-views");
// Files and strong models
string resultFromFile = engine.Parse("Test.cshtml", new Model("SomeData"));
https://andrewlock.net/configuring-environment-specific-services-in-asp-net-core/
https://inneka.com/programming/c/return-view-as-string-in-net-core/
https://medium.com/a-layman/refactor-your-html-report-with-razorengine-59e878ac9d52
https://stackoverflow.com/questions/40912375/return-view-as-string-in-net-core
https://ppolyzos.com/2016/09/09/asp-net-core-render-view-to-string/
https://ppolyzos.com/2016/09/09/asp-net-core-render-view-to-string/
https://long2know.com/2017/08/rendering-and-emailing-embedded-razor-views-with-net-core/
https://medium.com/a-layman/refactor-your-html-report-with-razorengine-59e878ac9d52
| Diagnostics; | |
| IO; | |
| Reflection; | |
| Tasks; | |
| ClassLibrary; | |
| Hosting; | |
| Internal; | |
| Razor; | |
| DependencyInjection; | |
| FileProviders; | |
| ObjectPool; | |
| PlatformAbstractions; | |
| Console | |
| { | |
| Program | |
| { | |
| args) | |
| { | |
| GetRenderer(); | |
| MyModel()); | |
| html); | |
| ReadKey(); | |
| } | |
| GetRenderer() | |
| { | |
| ServiceCollection(); | |
| Application; | |
| applicationEnvironment); | |
| GetCurrentDirectory(); | |
| HostingEnvironment | |
| { | |
| Name | |
| }; | |
| environment); | |
| => | |
| { | |
| Clear(); | |
| appDirectory)); | |
| }); | |
| DefaultObjectPoolProvider>(); | |
| diagnosticSource); | |
| AddLogging(); | |
| AddMvc(); | |
| RazorViewToStringRenderer>(); | |
| BuildServiceProvider(); | |
| RazorViewToStringRenderer>(); | |
| } | |
| } | |
| } |
| // Copyright (c) .NET Foundation. All rights reserved. | |
| // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | |
| System; | |
| IO; | |
| Linq; | |
| Tasks; | |
| Http; | |
| Mvc; | |
| Abstractions; | |
| ModelBinding; | |
| Razor; | |
| Rendering; | |
| ViewEngines; | |
| ViewFeatures; | |
| Routing; | |
| RenderViewToString | |
| { | |
| RazorViewToStringRenderer | |
| { | |
| _viewEngine; | |
| _tempDataProvider; | |
| _serviceProvider; | |
| RazorViewToStringRenderer( | |
| viewEngine, | |
| tempDataProvider, | |
| serviceProvider) | |
| { | |
| viewEngine; | |
| tempDataProvider; | |
| serviceProvider; | |
| } | |
| model) | |
| { | |
| GetActionContext(); | |
| viewName); | |
| StringWriter()) | |
| { | |
| ViewContext( | |
| actionContext, | |
| view, | |
| TModel>( | |
| EmptyModelMetadataProvider(), | |
| ModelStateDictionary()) | |
| { | |
| model | |
| }, | |
| TempDataDictionary( | |
| HttpContext, | |
| _tempDataProvider), | |
| output, | |
| HtmlHelperOptions()); | |
| viewContext); | |
| ToString(); | |
| } | |
| } | |
| viewName) | |
| { | |
| true); | |
| Success) | |
| { | |
| View; | |
| } | |
| true); | |
| Success) | |
| { | |
| View; | |
| } | |
| SearchedLocations); | |
| Join( | |
| NewLine, | |
| searchedLocations)); ; | |
| errorMessage); | |
| } | |
| GetActionContext() | |
| { | |
| DefaultHttpContext(); | |
| _serviceProvider; | |
| ActionDescriptor()); | |
| } | |
| } | |
| } |