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 5986415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:40:05+00:00 2026-05-22T22:40:05+00:00

I am analyzing a problem from an old asp.net site made by one of

  • 0

I am analyzing a problem from an old asp.net site made by one of my colleagues who left the company some months ago.

The problem is that we a few times have expierenced that two users sessions are mixed up, so that if for example two users are logged in, one user sees the other users data. As it happens very rarely (once in a month or so) it is difficult to figure out what goes wrong.

I have now stepped through his code for authentication and it goes like this:

  1. The user enter username/password on public page and press submit
  2. On Page_Load on Masterpage the code checks in a mySql database that the username/password is valid, not expired etc and return a unique userid if ok
  3. The page then saves the loginpage in session like this (used for later logout):
    HttpContext.Current.Session(Consts.CCookieName_LoginUrl) = Request.RawUrl
  4. Then the userid is saved like this: FormsAuthentication.SetAuthCookie(userid, False)
  5. Then a redirect to the secure area is performed: Context.Response.Redirect(secureurl, False)
  6. In Page_Init of masterpage of secure area the userid is read by: userid = Context.User.Identity.Name
  7. the user data is loaded acording to the userid
  8. The user navigates the secure area, ie. step 6 – 7 is repeated
  9. The user suddently sees another users data

I have some ideas on what is going wrong, but would like to have some input before modifying the code, so please anyone?

  • 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-22T22:40:06+00:00Added an answer on May 22, 2026 at 10:40 pm

    It’s hard to tell here.
    Have you configured Form Authentication?

    This is the process you have to follow for Form Authentication:
    In your web.config you setup the authentication system:

    <authentication mode="Forms">
        <forms loginUrl="Login.aspx" defaultUrl="Home.aspx" timeout="30" slidingExpiration="true" />
    </authentication>
    
    <authorization>
      <deny users="?"/>
    </authorization>
    

    Your login page (post-back) checks the credentials (not your master page).
    If the user is valid then you set the cookie:

    FormsAuthentication.SetAuthCookie(userid, False)

    and redirect to another page.
    Now, you have to set your principal reading the cookie here:

    protected void Application_AuthenticateRequest(Object sender, EventArgs e) {
        if (HttpContext.Current.User != null) {
            if (Request.IsAuthenticated == true) {    
                // Debug#1            
                FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(Context.Request.Cookies[FormsAuthentication.FormsCookieName].Value);
                // In this case, ticket.UserData = "Admin"                
                string[] roles = new string[1] { ticket.UserData }; 
                FormsIdentity id = new FormsIdentity(ticket);
                Context.User = new System.Security.Principal.GenericPrincipal(id, roles);
                // Debug#2
            }
        }
    }
    

    Obviously, I’ve simplified, but this is the path you have to follow to do things properly.

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

Sidebar

Related Questions

Can somebody suggest a good free tool for analyzing .Net memory dumps other than
Since yesterday, I am analyzing one of our project with Ndepend (free for most
What are some good tools for getting a quick start for parsing and analyzing
I'm trying to solve the following problem: I'm analyzing an image and I obtain
Analyzing Eye-movements on a screen, I set my origin to the bottom left corner
I have a WCF service accepting requests from our clients. After analyzing the request
I have a custom-made site which I want to migrate to a commercial solution
I am analyzing a .dmp file that was created and I have a call
I assume that most of the analyzing and tracking is done based on the
Does Ruby have any tools along the lines of pylint for analyzing source code

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.