Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6334837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:44:09+00:00 2026-05-24T18:44:09+00:00

I have a website that uses form authentication. For some reason it works fine

  • 0

I have a website that uses form authentication. For some reason it works fine at the first run. But on the second run it says too many redirects error.

Loginpage:Load event

 protected void Page_Load(object sender, EventArgs e)
            {
                if (Request.IsAuthenticated)
                {
                    Response.Redirect("HomePage.aspx");
                }

            }

Login Page submit credentials

 protected void btnSubmit_Click(object sender, EventArgs e)
        {
           int recordExistCount = fc.Authenticate(txtUsername.Text.Trim(), txtPassword.Text.Trim());
           if (recordExistCount == 1)
           {
               Session["User"] = "Authenticated";
               Session["Username"] = txtUsername.Text.Trim();
               fc.IsOnlineRecord(Session["Username"].ToString(),true);
               FormsAuthentication.RedirectFromLoginPage(Session["Username"].ToString(), true);
               Response.Redirect("HomePage.aspx");
           }
           else
           {
               lblStatus.Text = "Username or password specified are incorrect";
               lblStatus.BackColor = Color.Yellow;               
           }
        }

Masterpage signout button

protected void lbSignOut_Click(object sender, EventArgs e)
        {
            Session.Abandon();
            FormsAuthentication.SignOut();
            Response.Redirect("LoginPage.aspx");
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:44:10+00:00Added an answer on May 24, 2026 at 6:44 pm

    Try this

    On LoginPage.aspx

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["action"] != null && Request.QueryString["action"] == "logout")
        {
            Session.Abandon();
            FormsAuthentication.SignOut();
        }
        else
        {
            if (HttpContext.Current.User.IsAuthenticated)
            {
                Response.Redirect("HomePage.aspx");
            }
        }
    }
    
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        int recordExistCount = fc.Authenticate(txtUsername.Text.Trim(), txtPassword.Text.Trim());
        if (recordExistCount == 1)
        {
            Session["User"] = "Authenticated";
            Session["Username"] = txtUsername.Text.Trim();
            fc.IsOnlineRecord(Session["Username"].ToString(), true);
            FormsAuthentication.RedirectFromLoginPage(Session["Username"].ToString(), true);
        }
        else
        {
            lblStatus.Text = "Username or password specified are incorrect";
            lblStatus.BackColor = Color.Yellow;
        }
    }
    

    And on MasterPage Markup, place an asp:LoginStatus like this

    <asp:LoginStatus ID="AdminLoginStatus" runat="server" 
            LogoutAction="RedirectToLoginPage" 
            LogoutText="Log Out" 
            LogoutPageUrl="~/LoginPage.aspx?action=logout"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a website that uses #include file command to roll info into some
I have a website that uses basic ASP.Net forms authentication. In the web.config file
I have an existing website that uses the same code base, but is deployed
I have an asp.net website that uses forms authentication. There are a few things
I have an existing asp.net mvc website that uses basic forms authentication. The site
I'm coming across a peculiar request: I have a website that uses Forms Authentication,
I have a website with a form that uses PHP to send the form
I have the following form that uses some jQuery to allow an array of
I have a website that uses JSP as its view technology (and Spring MVC
I have a website that uses the facebook, twitter, delicious share links. They contain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.