Open Closed

Abp Routing #2011


User avatar
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)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    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());
        }
    }
    
    
  • User Avatar
    0
    MahmoudA created

    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)

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    CurrentUser.TenantId != null absolutely right!

  • User Avatar
    0
    MahmoudA created

    when i not authrized , i want to go to login page not home ? i means i don't want home page to show

  • User Avatar
    0
    MahmoudA created

    I solved it by return Task.FromResult<IActionResult>(Redirect("~/Account/Login")); when i not authorized Big Thanks .

Made with ❤️ on ABP v9.1.0-preview. Updated on December 10, 2024, 06:38