Reputation: 5677
Is this possible to do? I have the majority of my web app in MVC.
But I am going to set up a tech corner where I just want to go to simple Razor pages instead of setting up complicated endpoints to get there in StartUp.
Seems like pages would be better to organize simple pages like:
articles/AspNetCore3 -- list out related articles
articles/AspNetCore3/WhatsNew -- set up article here
articles/AspNetCore3/Blazor -- talk about this new technology here
articles/Azure/Overview -- these kinds of URLs with simple content but Razor Page ready to add functionality if needed
Upvotes: 0
Views: 707
Reputation: 912
You can use @RenderPage("_MenubarPage.cshtml");
.
You can also use @RenderPage("_MenuPage.cshtml", MyModel)
which allows you to supply any model you like to the view by including it as a second parameter.
You can also use @{Html.RenderPartial("_articles/AspNetCore3/WhatsNew");}
if you are using a partial. But don't forget that you need to wrap it with the razor code block @{}
The file path may be different depending on where you are rendering the Partial from.
In regards to using a Layout page, you simply just state what Layout you would like at the top of the cshtml page. Example below:
@page
@model Project.Pages.ProjectModel
@{
ViewData["Title"] = "Test Page";
Layout = "~/Pages/Shared/_Layout.cshtml";
}
You can also use the <partial>
tag to render a partial in .NETCore 3.1. Example below:
<partial name="Shared/_ProductPartial.cshtml" for="Product">
Tag helpers are the new thing in .NET Core. The HTML Tag helpers still exist for backwards compatability.
Microsoft Docs on Partial tags are located here
Upvotes: 3