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

  • SEARCH
  • Home
  • 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 7062017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:32:38+00:00 2026-05-28T04:32:38+00:00

So I have a login page where I set my own cookie and FormsAuthenticationTicket.

  • 0

So I have a login page where I set my own cookie and FormsAuthenticationTicket. However, when I finally choose to redirect the user to the new homepage after logging in, it refuses. It just redirects right back to the login page for no reason. I don’t understand why.

My web.config with part of the machinekey removed:

<authentication mode="Forms">
  <forms loginUrl="~/Login.aspx" defaultUrl="~/Default.aspx" cookieless="UseCookies" name=".ASPXFORMSAUTH" timeout="50" />
</authentication>
<authorization>
  <allow users="*" />
</authorization>
<machineKey decryption="AES" validation="SHA1" ........ />

My Login click event after entering username/pass and authenticating it as true:

if (Authenticated)
    {
        //Create Form Authentication ticket
        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, userName, DateTime.Now, DateTime.Now.AddMinutes(30), false, userName, FormsAuthentication.FormsCookiePath);
        string encryptedCookie = FormsAuthentication.Encrypt(ticket);
        HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedCookie);
        Response.Cookies.Add(cookie);
        Response.Redirect("MainPage.aspx", true);
    }

MasterPage checks to make sure only certain pages can be accessed:

else if (Context.User.Identity.IsAuthenticated)
    {
    if (Session["uid"] == null)
    {
          userclass u = new userclass();
          int uid = -1;
          uid = (int)u.Getuseridbyusername(Context.User.Identity.Name);
        if (uid != -1)
        {
            Session["uid"] = uid;
        }
    }
    } else if (!Context.User.Identity.IsAuthenticated)
    {
      // First check if user is was redirected to ChangePassword
      if (!Request.Path.Contains("ForgotPass.aspx") && !Request.Path.Contains("ChangePass.aspx") && !Request.Path.Contains("CreateAccount.aspx") && !Request.Path.Contains("Error.aspx") && !Request.Path.Contains("Logout"))
      {
         if (!Request.Path.Contains("Login"))
            FormsAuthentication.RedirectToLoginPage();
      }
    }

Commenting out RedirectToLoginPage() has no effect. Trying to use RedirectFromLoginPage has no effect. Trying to use <allow users=”?” /> has no effect. Trying to use <deny users=”?” /> in conjunction has no effect.

EDIT: Cookie is set according to browser traffic. But no redirect is coming through. Apparently, either you cannot redirect after setting a cookie or ASP.NET doesn’t know how to read instructions.

  • 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-28T04:32:39+00:00Added an answer on May 28, 2026 at 4:32 am

    Solved. Apparently, I did have a Redirect somewhere that was taking the user back to the login page even though the cookie is set and Context.User.Identity.IsAuthenticated was returning true because the session variable “uid” was being set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I have set up a login page that verifies the user's credentials, and
I have a login page where I authenticate the user. When the authentication pass,
I have created a user login page and am using Forms Authentication. Users are
Is it possible to set a session cookie on login.app.com, and have the session
Normally we have login page with username, password filed and signin button. Using the
I have a login page that has several textboxes on the page, one of
I'm using ASP.NET MVC 2 and have a login page that is secured via
I have a problem on my site's login page in IE7 browser. One of
I have this situation: There are a login page with a login form (form
I have an application I would like to force SSL on the login page

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.