locked
.net core how to render to login page after login? RRS feed

  • Question

  • User-790790109 posted

    what can I do to redirect user to Index HomeController page? Note: I'm using the default authetication layout of .NET CORE 2.1.

    Tuesday, August 13, 2019 8:26 AM

Answers

  • User-790790109 posted

    The soluction:

    Open the login.cs file under razor file and find the login action, after put this:

     _logger.LogInformation("User logged in.");
    return RedirectToAction("Index", "Home");

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 13, 2019 2:19 PM

All replies

  • User-1038772411 posted

    Hello, Valdanio

    Not clear what you exectly want, but for my understanding after login autentication you want to redirect in dashboard like page and after logout back to login.

    so, in asp.net core you can user :  return this.RedirectToPage("/Home/Index");   

    Reference Link : full code of asp.net core with code first approch you can use only as per our current reqirement only.

    https://www.c-sharpcorner.com/article/asp-net-core-razor-pages-simple-login-using-entity-framework-database-first-app/

    Thanks.

    Tuesday, August 13, 2019 12:23 PM
  • User1289604957 posted

    Hi,

    what can I do to redirect user to Index HomeController page?

    services.ConfigureApplicationCookie(options => options.LoginPath = "/Home/Index");

    Best regards,

    Maher

    Tuesday, August 13, 2019 12:24 PM
  • User-790790109 posted

    The soluction:

    Open the login.cs file under razor file and find the login action, after put this:

     _logger.LogInformation("User logged in.");
    return RedirectToAction("Index", "Home");

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, August 13, 2019 2:19 PM