Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Add ViewComponentResult helper methods to Page \ PageModel #7051

Closed
pushqrdx opened this issue Nov 14, 2017 · 6 comments
Closed

Add ViewComponentResult helper methods to Page \ PageModel #7051

pushqrdx opened this issue Nov 14, 2017 · 6 comments

Comments

@pushqrdx
Copy link

In the underlying PageModel i want to return a ViewComponent from a OnGet request. I am trying return ViewComponent("ComponentName"); but it throws an error non-invocable member ViewComponent

@pushqrdx pushqrdx changed the title Using ViewComponent in Razor Pages Using ViewComponent in Razor Pages' PageModel Nov 14, 2017
@pranavkm
Copy link
Contributor

@pushqrdx PageModel is missing the ViewComponent helper factory methods. You could define a custom base class with these methods (https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc.ViewFeatures/Controller.cs#L204-L276) or return an instance of ViewComponentResult from your handler method.

@rynowak \ @DamianEdwards were the ViewComponent family of helpers also intentionally not ported over or did we just miss porting them?

@pushqrdx
Copy link
Author

@pranavkm You saved me, is there any reason it isn't there ?

@pranavkm
Copy link
Contributor

@pushqrdx returning view components from a handler isn't a pattern we expect users to commonly use in a page-focused workflow. One of my suggestions from the earlier comment or perhaps a couple of extension methods should do the trick in your case.

@mkArtakMSFT
Copy link
Member

@pranavkm, can you please handle this?

@pranavkm
Copy link
Contributor

pranavkm commented Jan 3, 2018

@mkArtakMSFT we specifically chose not to port the helper over - see #5846. Is the plan to port them?

@mkArtakMSFT
Copy link
Member

@pranavkm, yes, let's do it. We've just synced up with @rynowak regarding this too.

@mkArtakMSFT mkArtakMSFT modified the milestones: 2.1.0-preview2, 2.2.0 Jan 31, 2018
@pranavkm pranavkm changed the title Using ViewComponent in Razor Pages' PageModel Add ViewComponentResult helper methods to Page \ PageModel Feb 6, 2018
@mkArtakMSFT mkArtakMSFT modified the milestones: 2.2.0, 2.2.0-preview1 May 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants