Qadeer Qadeer - 3 months ago 32
ASP.NET (C#) Question

Render a View inside a View in Asp.Net mvc

How do I render a full fledged view (not partial view) inside another view?

Scenario, I have different controller and want the exactly same view to render which is already there under other controller with different layout.

I have Wishlist page in Home Controller which shows list of added products, and when user logged in , when I click on wish list it also show me navigation when user is signed in.

How would I do that??

Answer

Not many developers know about this but you can use RenderPage, it's specifically designed for that purpose(to render an MVC view inside another view)

@RenderPage("~/Views/Shared/SampleView.cshtml")