How to change home page route in Orchard Core

139 Views Asked by At

I am trying to use Orchard Core and I need to replace the Home page route to match with the previous settings, alternatively I could move my files but I want to explore the framework and it is a learning experience, from searching I found out that I perhaps need to create a module and then use that to reroute to the current home page, but it is a bit unclear.

Any guidance is much appreciated.

This is from the old code, and the functionality that I am trying to re-creeate.

builder.Services.AddRazorPages(options =>
{
  options.Conventions.AddPageRoute("/Home/Index", "");
});
2

There are 2 best solutions below

0
Martin Brown On

This may not be quite what you are doing, but I had trouble setting the home page with the Admin site.

What I found was that you have to go into the Configuration/Feature section and enable both the Auto Route and Home Route features. Once you've done that it is possible to go into a Content Type and add an auto route part. Following that you can edit the auto route part's settings to enable Show Homepage Options. Finally when you create a content item of that content type it allows you to select that it should be the home page. Note that it only becomes the home page once published.

0
Ashraf Sabry On

You set your landing page URL using an Autoroute part to whatever you want then, in your startup class redirect the root path to that URL, for example:

app.MapGet("/", ctx =>
{
   ctx.Response.Redirect("YOUR URL HERE");

   return Task.CompletedTask;
});