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.

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

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());
        }
    }
    
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • 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)

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    CurrentUser.TenantId != null absolutely right!

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • 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

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    MahmoudA created

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

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.