Hi
In below line where RedirectToLoginPage(); is to defined. Do we need to give in Web.Config
C#
FormsAuthentication.RedirectToLoginPage();
-->Thanks
Hi
In below line where RedirectToLoginPage(); is to defined. Do we need to give in Web.Config
FormsAuthentication.RedirectToLoginPage();
-->Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Gowtham CpRank #1,552 · 1K reputationPosted Aug 20, 2024, 10:44 PM EDT
You don't need to define
RedirectToLoginPage()inweb.config. That method is used in your C# code to redirect users to the login page when they’re not authenticated. Yourweb.configjust sets the login page and other settings, like this:In your code, you’d use
FormsAuthentication.RedirectToLoginPage();to handle the redirection.if (!User.Identity.IsAuthenticated) { FormsAuthentication.RedirectToLoginPage(); }