Open Closed

Overriding redirect for home page to login view #1211


User avatar
0
joe@tronactive.com created
  • ABP Framework version: v4.2.2
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no

I want to redirect a user to the actual login page https://localhost:44343/Account/Login if they are not logged in. Not the home page. I tried adding an override HomeController but it doesn't seem to be overriding the frameworks. I put a break poing in the Index method and it never gets hit. Any ideas why?

[Dependency(ReplaceServices = true)] public class HomeController : AbpController { public ActionResult Index() { if (CurrentUser.IsAuthenticated) { return View(); }

        return Redirect("/Account/Login");
    }
}
Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi joe@tronactive.com

    I want to redirect a user to the actual login page https://localhost:44343/Account/Login if they are not logged in. Not the home page.

    How to reproduce this?

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

    Instead of going to the Home page with the login button. I want it to go to the https://localhost:44343/Account/Login. As you can see the images below. I was able to do this in the Angular version with the API with a HomeController and the below code. But in the MVC app it doesn't work.

    public class HomeController : AbpController { public ActionResult Index() { if (CurrentUser.IsAuthenticated) { return View(); } return Redirect("/Account/Login"); } }

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

    Nevermind, I was being stupid. I created a Home folder under Views/Home and then moved the index.html file from the Pages folder to that Views/Home folder and it worked as I wanted it to.

    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, 07:12
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.