Starts in:
2 DAYS
9 HRS
56 MIN
2 SEC
Starts in:
2 D
9 H
56 M
2 S
Open Closed

How to route to the dashboard without landing Index page? #308


User avatar
0
alper created
Support Team Director

Project: MVC + Tiered. I want to skip the /Index page and route to Login page and after the successfull login, I wan to route to the Dashboard page.


1 Answer(s)
  • User Avatar
    0
    alper created
    Support Team Director

    Change your Index.cshtml.cs to

    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Authentication;
    using Microsoft.AspNetCore.Mvc;
    
    namespace Mvc.Tiered1.Web.Pages
    {
        public class IndexModel : Tiered1PageModel
        {
            public async Task<IActionResult> OnGetAsync()
            {
                return RedirectToPage(CurrentUser.TenantId.HasValue ? "/TenantDashboard" : "/HostDashboard");
            }
    
            public async Task OnPostLoginAsync()
            {
                await HttpContext.ChallengeAsync("oidc");
            }
        }
    }
    

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06