Open Closed

how change redirect url after login in web project based in role? #9430


User avatar
0
devmahmod created

i have user in role ContentManager i want when user login redirect to ManagerRequests how to solve , I'm using mvc core razor

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

2 Answer(s)
  • User Avatar
    1
    maliming created
    Support Team Fullstack Developer

    hi

    You can add the redirect code in the Index page. This is easiest

    public ActionResult Index()
    {
        if (CurrentUser.IsAuthenticated && CurrentUser.Roles.Contains("ContentManager"))
        {
                return Redirect("~/ManagerRequests");
        }
        return Page();
    }
    

    You can also do it in the OnSignedIn method.

    context.Services.ConfigureApplicationCookie(options =>
    {
        var previousOnSignedIn = options.Events.OnSignedIn;
        options.Events.OnSignedIn = async cookieSignedInContext =>
        {
            await previousOnSignedIn(cookieSignedInContext);
    
            var currentUser = cookieSignedInContext.HttpContext.RequestServices.GetRequiredService<ICurrentUser>();
            if (currentUser.IsAuthenticated && currentUser.Roles.Contains("ContentManager"))
            {
                cookieSignedInContext.HttpContext.Response.Redirect("api/account/authenticator-info");
            }
        };
    });
    }
    
    
    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

    Great!

    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.