-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature - Add support for Razor Class Library views #64
Comments
Here is an example project with two RCL's, one statically linked to the web project, one loaded dynamically. By default new RCL's use MVC Areas but I've tried it without areas and get the same result, can call a controller and get a content result but when it returns a view it can't be found. |
Hi James, Thanks for your interest, I take a look at your example and see what the culprit is. Prise/src/Prise.Mvc/PriseMvcExtensions.cs Line 69 in 15432b2
|
Thanks so much! I was able to load and render Razor Pages if I add a CompiledRazorAssemblyPart after the PluginAssemblyPart. That seems to match how the statically linked RCL works. I added diagnostic views to the example home page so you can see the routes & parts before and after enabling a plugin. I think the backwards compatability is less of an issue for me, through unloading the assemblies is definitely something I'd hope to preserve. I'll do some tests loading/unloading RCL's with their views to see what sort of objects stick around after they should be gone. I think the only remaining piece I haven't gotten working is the view location, the controller can be called, razor pages rendered but when it looks for an MVC view it fails - probably a view location list that is created at startup and needs to be updated on load/unload. |
Found it! Needed a CustomViewCompiler that could be reset (Hot Reload does this with the default one). I added a CompiledRazorAssemblyPart along with the PluginAssemblyPart and reset that cache and now it loads and displays the view. Will try to clean it up and see if I can add the new views rather than clearing the entire cache. Guess I'll also need to remove views that are being unloaded. So close.. |
@jakenuts Any luck with this, im using it with blazor and im so close |
First let me say, remarkable work. This is absolutely the closest I've found to the "holy grail" of hot-swappable MVC controllers & views. That it unpacks nuget packages and loads from there is 100% what I've dreamt of (short of a service that polls nuget feeds and downloads updates to the plugins folder).
I tried adding Prise to a solution with one main WebApp and several Razor Class Libraries with their own views and controllers and was able to load/update one of the RCL projects at runtime. The only flaw I ran into there was that the views (usually merged into the main project at build/start) weren't found so I could only return content results.
I may be pushing this farther than was intended, or farther than anyone has time to devote to making possible but if down the road you could reference & update RCL packages at runtime that would be a stunning achievement.
Thanks again!
James White
The text was updated successfully, but these errors were encountered: