-
Notifications
You must be signed in to change notification settings - Fork 25.3k
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
Please give an example of returning a Partial View from a Razor Page method #8188
Comments
@rynowak please review. |
@RyanTaite did the samples in #8132 help? Would you be able to help @guardrex getting this documented? |
@RyanTaite, you've posted some great info, thanks. Let me hack around with it, too, and we can compare notes. I should be able to get to this soon ... early next week. |
@Rick-Anderson Yes, pranavkm's examples seem to be exactly what I was after in regards to returning a Partial View from a Razor Page @guardrex I'm happy to help with updating the documentation. I'll see what I can do later, I think I would also be in the early next week timeline. |
@RyanTaite Sure thing. Let me know if you decide that you want to write the section or just review what I write to make sure that I'm covering the bases. I just saw the examples, too. I think we'll be in good shape getting this covered next week. |
@guardrex I think I'm going to lean towards reviewing your write up, since I've really only done very small updates here-and-there to the docs as I've walked-through tutorials. That said, I'll still try to write up my own to compare against yours and learn how to make larger edits like this. Hope that's alright. |
Sure ... np. I envision this will be a section added to this topic (I think). I'll know more when I take a closer look. The section will include versioning ("moniker ranges") to display content for 2.1 vs. 2.2 or later. It looks like there isn't a 2.0 workaround according to what was posted on the other issue. I'll be sure to ping you on the PR. At the current rate of work, I think I'll be on this by Tuesday/Wednesday next week ..... if everything goes smoothly. 🏃🏃🏃🏃😅 |
@Rick-Anderson @scottaddie The topic ... Partial views in ASP.NET Core ... focuses on MVC views ... really heavily focuses on views with lots of "MVC" and "view" language. We have two options:
If we're going to have two or three RP samples/approaches for this, Option 2 looks better to me. If we only go with one 2.2 sample, then perhaps Option 1 is the way to go. There are existing samples for 2.1 and 2.2. A few options are ...
Note that I don't have a 2.0 approach. See: #8132 (comment) I'm leaning in the direction of one 2.2 sample and one topic that covers both MVC and RP (leave it under MVC and link it under the RP TOC node). That's the greatest bang for the buck in terms of content generation and maintenance costs. 💰 However, let me know what you prefer. |
@guardrex I'm in favor of 1 topic that covers both MVC and RP. The single 2.2 sample should work too. |
@scottaddie Agreed. This is a good Saturday morning project for me. I'm looking forward to it! 😄 |
Born from this issue: #8132
Currently, I only know how to return a Partial View in a .Net Core 2.1 Razor Pages web app by using a Controller.
I wrote an example project of this here: https://github.com/RyanTaite/DynamicListExample
I would like to know how this can be done from a Razor Page method instead.
Copying from my comment on the above issue:
In
Startup.cs
'sConfigure
method I had to add:app.UseMvc(routes => routes.MapRoute("default", "{controller}/{action=Index}/{id?}"));
Then I add a Controller:
And I can call that with a
@Url.Action("GetChildPartialView", "Parent")
from my View/Ajax methodBut, I would like to point out that
PartialView("_ChildPartialView", new Child());
throws an error saying:It actually can find and return
_ChildPartialView
though. So there will be an error for everyPartialView("_somePartialView", ...)
method call that you just have to ignoreChanging it to
PartialView("Shared/_ChildPartialView", ...)
gets rid of the error in Visual Studio, but fails to locate the View when running the application because it's looking for it in aView
folder that doesn't exist.I don't know how to override that behavior.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: