Obsoleting Razor Runtime Compilation Recommendations #63417
Replies: 1 comment
-
In the announcement they said "Developers could use Razor runtime compilation to recompile .cshtml files while the application is running.". That's not the only thing people use it for. I'm using runtime compilation to provide dynamic content support in various projects, perfect to load views and layouts from the DB or another place. Would be a shame if it's not going to work anymore in the future. Hot Reload is something completely different, not usable for runtime stuff (or for it's real purpose, it's extremely flaky, even with Blazor...). I cloned the runtime compilation source code, and it's working without problems locally so far. Let's hope they won't remove stuff in the future that's needed to make it work. If it stops working maybe it's possible to compile the views to a DLL with a command line app, and load the assembly at runtime. Should be possible with a custom View Engine and/or View Compiler. Last resort is to convert all the templates to another template language (maybe something like Liquid .NET version: fluid (even has a MVC View Engine), but that's a lot of work... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
After reading aspnet/Announcements#522 I am looking for some guidance.
We have created multiple multi-tenant applications that internally utilize Razor views for reporting.
These applications support customer-specific reports that are stored in the database (these reports are custom-made by us)
The ability to recompile a Razor view during production using runtime compilation has been proven invaluable, as we can update reports without having to rebuild and redeploy the application.
In the announcement, the recommended action is to use HOT Reload during development, but there is no mention of how to achieve the same functionality in production.
To get an impression of how we generate the views, we use the
IRazorViewEngine
and call itsRenderAsync
method to generate the viewDescribe the solution you'd like
Is there a way we could leverage the HOT reload functionality during runtime in production so we can get similar functionality by providing it a
razor.cshtml
file, and it generates anIView
we can use to generate the HTML?I am open to other suggestions
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions