Replies: 9 comments
-
You don't need to redirect anything. If you specify your controller action's route as the home route (I think just "/" should work), like with attribute routing then that's what will come up when you open the homepage. |
Beta Was this translation helpful? Give feedback.
-
Hi, this doesn't work: |
Beta Was this translation helpful? Give feedback.
-
How exactly is it not working? |
Beta Was this translation helpful? Give feedback.
-
It ignore this route, still directly go to the landing page. |
Beta Was this translation helpful? Give feedback.
-
Let's try to make this work in a simplest way: Please create a controller in your module where the action just returns a string or something, and use attribute routing to hook it to the homepage. Enable the module, then try it out. If it doesn't work then open the action directly with the default route. Let us know if this works and post your code. |
Beta Was this translation helpful? Give feedback.
-
You can change the homepage route by changing it in the database. You will do this SQL Query to find the proper record in the DB : SELECT * FROM Document WHERE Type = 'OrchardCore.Settings.SiteSettings, OrchardCore.Settings'
And then change this part of the JSON data with what you need : {
"HomeRoute": {
"area": "OrchardCore.Contents",
"controller": "Item",
"action": "Display",
"contentItemId": "12121212121212"
}
}
Let's add this to the documentation please as this question is often asked. @agriffard |
Beta Was this translation helpful? Give feedback.
-
@Skrypt I tried to create a Tools module with an admin page to set the HomeRoute. The homeRoute is correctly updated but, it still needs to update the current one to SetHomepage = false and if there is a contentItemId, update the content that has the new contentItemId with SetHomepage = true. If you want to take a look: |
Beta Was this translation helpful? Give feedback.
-
You just need to disable the So if you disable the
|
Beta Was this translation helpful? Give feedback.
-
Just for those stumbling on this, looking for a solution to override other routes than the home route: with the public class Startup : StartupBase
{
public override int Order => -100;
public override void Configure(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider)
{
var userOptions = serviceProvider.GetRequiredService<IOptions<UserOptions>>().Value;
routes.MapAreaControllerRoute(
name: "UsersLogOff",
areaName: "MyModule",
pattern: userOptions.LogoffPath,
defaults: new
{
controller = typeof(MyAccountController).ControllerName(),
action = nameof(MyAccountController.LogOff),
}
);
}
} |
Beta Was this translation helpful? Give feedback.
-
As I'd like to redirect the homepage to use my own controller /Home/Index
Beta Was this translation helpful? Give feedback.
All reactions