You don't typically pass a page around in razor pages. Your razor page itself is the object that gets injected into the attached view.
Instead return Page()
and make the _layoutViewModelFactory return its object to the property of the page. Since its a layout object, you'll want to create a BaseRazorPageModel which contains your layout object then have your razor page inherit from there.
It's not clear from your screenshots but your razor page should consist of a view and page model thats bound together. If you're using VIsual Studio you should see the Page Model hanging off the view in the solution explorer.
Hi Christian
You might need to check the following 2 things
#1 - Have you configured endpoint routing for razor pages in your Startup?
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
});
#2 - What do you place your razor pages? By default, the asp.net core runtime look for Razor page file in the /Pages folder.
I hope above helps.
Hi Christian
I did a quick test using Optimizely empty commerce template, it seems working fine with default razor pages configuration and convention (see screenshot below). At this stage, I think you might have some advanced configurations in your solution that alter the routing behavior.
Hi,
I am having trouble creating a razor page for commerce content.
I have this generic product:
And this razor page:
However, when visiting a product, I get an 404.
If I create a similar page, but with MVC as below:
I am infact able to get a result.
Is razor pages not supported for commerce?