-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Plugin System—Providing PartialViewResult with no Model #4886
Comments
@NTaylorMullen, any thoughts? Thanks! |
Hi, Here the context. I have built a plugin system for my Asp.Net Core MVC webapp. DiagramEmbedded PluginsEach plugin have its own MVC components (With Get and Post… so View Components are not useful here).
How it looksApi Provider based pluginsI use Ajax call to load the content of "Api Provider based plugins" in div tags, as they are potentially "deadlocks" for my app (depending on the Api request, and failures, It can take at least 3 seconds to load the page, or unlimited time…). "Local plugins"Here is the problem. But, as we can see in the provided link, "the caller" of RenderPartialAsync feed the called controller with its own model or viewData, leading to mismatch between what the plugin controller need, and what the caller of RenderPartialAsync give. For now I use for any plugin Ajax Call. But if we had something like "No Model at all RenderPartialAsync", we could use it as embed like tag for Asp.Net Core MVC. Hope I am clear enough. |
Are you suggesting a different method that doesn't default If so, is |
Yes
As long as it does not feed with null object the called controller (always the mismatch problem between the needed model for the callee and the null object send…). |
@NTaylorMullen, is there anything else you need to add here, or should this be closed already? Thanks! |
@NTaylorMullen No comment? |
@davidfowl |
@ckams it sounded like there's an existing API that works for your scenarios today. Is this specifically about having an overload without a As a side note, we also introduced a PartialTagHelper in 2.1.0, which we'd recommend over HtmlHelper.Partial* going forward. You should be able to specify a |
@ckams I apologize for the deaf ear. We get a load of issues that we need to get through daily. I was under the assumption that the Also, @pranavkm's suggestion of partial TagHelper is a fine alternative as well. |
Indeed! And I prefer to depend the least possible to API, and keep, to the MAX, pure ASP.NET CORE code.
Well, sounds perfect!!! Is there any documentation about this? I want to try this :) |
Well it does not work. The problem resides here, — forgot to put this before —or here. First, let me coming back to this:
Let me explain again. If you take a look at the discussion on the asp.net forum, you will see that I have embedded Plugins in pages (you can see, as well, this on this issue). If I use I will get: If I use I will get: In pictureThe benefitsSo here the benefits Why?
All of this, with a simple function that return the raw output from the called controller. |
I can even say that lazy loading shows why it can be useful, as it
If the "Blazor team" see any benefits to provide this kind of feature (and developers will enjoy! Me too :D), why ASP.NET Core MVC team and developers will not find this useful? It's illogical. Because I only try to achieve the same thing in "full" ASP.NET Core MVC. |
No more problem like this… |
I don't see this - https://github.com/pranavkm/partial-null/blob/master/Pages/Index.cshtml#L4. |
@pranavkm Anyway, if you look at HtmlHelperPartialExtensions.cs, you will see that a Model/ViewData is sent. With Plugin built around Application Parts, with its own MVC components, the caller feed the called with its Model. Hence the errors. |
Is there a repro app you could share with us? Your original requirement was to have a way to pass in a null model to a partial which, like I showed, works fine, Beyond that, for your plugin requirements, we generally recommend using a module system like the one OrchardCore projects. It's generally more well tested and addresses the kinds of problem you're attempting to solve in your hand rolled implementation. |
No, only on local server. But I will try to setup something on github, with pleasure if you ask. Even a PR :p
No, in my original requirement, I stated:
I wrote without object model, ViewDataDictionary viewData meaning empty. Sorry for this misunderstanding.
Well with a "small"
The cost for the ASP.NET Core MVC is null, but the benefit for developers is huge. You know, you can find the same kind of feature on other projects. From memory, Joomla provides such feature on the CMS and its framework… Their plugins are mini MVC apps, that you can embed in any page, etc… |
If you take a look at the topic on the forum, you will see that my requirement has never changed…. You did not understand it, I can conceive that it's my fault, but I insist, I never change anything in my request. So to summarize I ask for a kind of
Finally, I repeat, if you ask, I can setup what you asked for, and even a PR. |
I've a sample that shows using a PartialTagHelper, you're able to do essentially what this new API requires. If there's a feature gap with the tag helper, which you have yet to have demonstrate, we can consider addressing it. Beyond that, we do not plan on adding new APIs to HtmlHelper. |
But this is, here, useless, as null object is sent to the Plugin Controller leading to rise an exception… The behavior is the same as in 2.0…
Well, I will try to put something that you can test. Will it be enough? But you wrote:
Does it mean that under no circumstances you will add a new APIs to HtmlHelper? But here the problem… And if it is the case, I will not waste my time to show you something, while it is hopeless… |
Hi @ckams. It seems there is some kind of confusion here and from reading through your forum post, it seems you really haven't understood that folks here were trying to help you. Not really best way to speak about people without understanding them. Anyway, the bottom line here is that we still don't understand the exact problem that you want us to fix. So a repro app which would explicitly detail out the scenario as well as the problem you're facing would definitely help. Please go ahead and provide the requested info so we can try to help. |
Hi @mkArtakMSFT But, it is, for me, so obvious, and only by looking at the code, that it becomes annoying. Anyway, I will do my best to detail the problem. |
Hi, |
@pranavkm
I always see the same problem… The It is obvious, read the code. And here, this is a simple "plugin"… In any way similar to SMS, SignalR, Analytics Plugins, etc… where their Model will be dropped too… |
In my humble opinion, this "trick" looks more like a View Components alternative. |
See my request like a TagHelper — coupled with a From what I read in the ASP.NET Core MVC code, there is, for now, no existing way, in ASP.NET Core MVC, to achieve what I want. Again, read your own ASP.NET Core MVC code. |
@pranavkm to clarify the situation, I often point to And whatever you will propose that differs, will not feat the expectation of most of ASP.NET Core MVC developpers. |
Hi @ckams. Just to confirm that my understanding is correct, are you looking for a new mechanism, which will allow you to pass in arbitrary model to a view, which you try to load using |
Hi @mkArtakMSFT |
@ckams, so you want the mechanism to end up loading views, even thought the model doesn't match. So that you can define in the view which model to use dynamically? |
Well, that depends of what you mean by 'the model doesn't match'.
|
Ok. I now understand your ask. |
Finally! :) |
Hi. Thanks for contacting us. |
Could be related:
aspnet/Mvc#6984
#343
aspnet/Mvc#4572 (comment)
What about providing
RenderPartialAsync/RenderPartialCoreAsync
versions withoutobject model, ViewDataDictionary viewData
?Coupled with Application Parts, we would have, out of the box, everything ready to add a Plugin System.
(Each Plugin with its own MVC, embedded in the "webapp-host" pages.)
The text was updated successfully, but these errors were encountered: