0
MahmoudA created
I want to change default page to dashboad.
Exmaple : when login as host redirect to host dashboard (not home) when login as tenant redirect to tenant dashboard (not home)
How can i do this ? I use mvc project.
5 Answer(s)
-
0
hi
You can redirect the user in Index page.
public class IndexModel : MyProjectNamePageModel { public Task<IActionResult> OnGetAsync() { if (CurrentUser.IsAuthenticated) { if (CurrentUser.TenantId == null) { return Task.FromResult<IActionResult>(Redirect("~/Dashboard")); } else { return Task.FromResult<IActionResult>(Redirect("~/HostDashboard")); } } return Task.FromResult<IActionResult>(Page()); } }
-
0
hi
You can redirect the user in Index page.
public class IndexModel : MyProjectNamePageModel { public Task<IActionResult> OnGetAsync() { if (CurrentUser.IsAuthenticated) { if (CurrentUser.TenantId == null) { return Task.FromResult<IActionResult>(Redirect("~/Dashboard")); } else { return Task.FromResult<IActionResult>(Redirect("~/HostDashboard")); } } return Task.FromResult<IActionResult>(Page()); } }
Thank you for your solution. it works with me after change the condition (CurrentUser.TenantId == null) to (CurrentUser.TenantId != null)
-
0
CurrentUser.TenantId != null
absolutely right! -
0
when i not authrized , i want to go to login page not home ? i means i don't want home page to show
-
0
I solved it by
return Task.FromResult<IActionResult>(Redirect("~/Account/Login"));
when i not authorized Big Thanks .