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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:12:29+00:00 2026-05-15T20:12:29+00:00

Here’s what i have : ASP.NET 4.0 Web Application Forms Authentication (Cookie Based) Here’s

  • 0

Here’s what i have:

  • ASP.NET 4.0 Web Application
  • Forms Authentication (Cookie Based)

Here’s what i’m trying to do:

  • Integrate with Facebook Connect (using the JavaScript & Graph API’s)
  • Provide a Single-Sign-On Service for my users (automatically log in
    users if their logged in and connected
    to Facebook)

On every page there is a control which shows anonymous/logged in user details.

Here’s the issue:
On Page_PreRender of this user control (which is on every page, so consider this event being executed on every single page request), i attempt the auto-sign on based on the Facebook Authentication status (JavaScript API – Cookies).

If the sign on is successful, i log them in using FormsAuthentication.SetAuthCookie.

This is all working fine.

However, right after i do single sign on (literally the next line), i need to render out either the anonymous stuff (please sign in) or the authenticated user stuff (display name, etc). The problem is, the user isnt really “authenticated” to my site yet. To be “authenticated” to my site i do standard stuff (check the HttpContext.User.Identity.IsAuthenticated property).

I think its not yet set to "true” because the Forms Auth cookie has been created, but thats in the response, the HttpContext.User.Identity.IsAuthenticated is based on the request at this point in time – am i right there?

So of course, its showing the anonymous details even though the user is logged in.

When i refresh the page of course, the correct user details are shown.

So its almost a timing issue. How can i auto-login a user (via FormsAuthentication.SetAuthCookie) ensuring the HttpContext.User.Identity.IsAuthenticated is true?

Maybe im doing the authentication/single-sign-on in the wrong place?

Or do i need to almost do a Response.Redirect to myself in order to refresh the cookies in the HTTP Request?

As you all know, the doco for Facebook Connect is scattered and minimal, so its all a matter of piecing things together.

Any help would be appreciated…cheers!

  • 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-15T20:12:29+00:00Added an answer on May 15, 2026 at 8:12 pm

    Okay i found the answer (and it was the answer that i hoped WOULDN’t be the answer).

    As i predicted, FormsAuthentication.SetAuthCookie creates an authentication cookie in the HTTP Response Stream. But HttpContext.User.Identity.IsAuthenticated reads the HTTP Request Stream (which does not have the cookie).

    So the solution is to programatically refresh the page using Response.Redirect(this.Context.Request.RawUrl, true) (second parameter terminates current page execution) to reload the cookie in the HTTP Request.

    This is why i guess we always have a Login.aspx page which sets the forms cookie then redirects somewhere, because by the time the redirect to “somewhere” happens, another request is made so the cookies are refreshed.

    I’ll probably put the Facebook Authorization stuff in a standalone .aspx page so and do it the same way as regular forms auth.

    Oh and the “refresh” idea was mentioned by a Microsoft Person here.

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

Sidebar

Related Questions

Here is the problem that I am trying to solve. I have two folders
Here is what I am trying to achieve in PHP: I have this string:
Here's my code, what I'm trying to do is have javascript check a form
Here is the code in a function I'm trying to revise. This example works
Here is the Javascript I currently have <script type=text/javascript> $(function() { $('.slideshow').hover( function() {
Here's the basic setup: I have a thin bar at the top of a
Here is my problem : I have a post controller with the action create.
Here's what I'm trying to accomplish with this program: a recursive method that checks
Here is the css: #content ul { font-size: 12px; } I am trying this:
Here is an example: I have the generic type called Account. I wish to

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.