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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:42:53+00:00 2026-06-03T16:42:53+00:00

Problem fixed, see below What I’m doing is this: Generate random number -> store

  • 0

Problem fixed, see below

What I’m doing is this:

Generate random number -> store it in a session -> pass it to facebook with the ‘state’ parameter of Facebook’s OAuth service -> verify that the returned state is the same as the state in my session (this is done for CSRF protection).

This always worked, no problem. But somehow, it’s not working any longer (the Session seems to be empty because I’m getting a NullReferenceException when I try to read it). I probably changed something, but I can’t find out what.

I tried setting breakpoints in the part of the code where the state is returned by facebook, but somehow it will never hit the breakpoints… The code between my breakpoints get executed, but my breakpoints are not hit.

This is the code that is executing everything:

public ActionResult SignUpButton()
{
    int random = RandomHelpers.GetRandomInteger(null);
    Session.Add("facebookState", random.ToString(CultureInfo.InvariantCulture));

    ViewBag.Uri = "https://www.facebook.com/dialog/oauth?" +
        "client_id=" + _facebookAuthenticationService.GetAppId() + 
        "&redirect_uri=" + _facebookAuthenticationService.GetReturnUri() + 
        "&scope=email" +
        "&state=" + random;

    return PartialView();
}

public ActionResult Register()
{
    string error = Request.QueryString["error"];
    string state = Request.QueryString["state"];
    string originalState = Session["facebookState"].ToString();

(I removed the rest for brevity). The SignUpButton function returns a partial view containing a button with the sign up URL that leads to facebook. Facebook returns to localhost:xxx/Account/Register (that’s the Register function), this functions gets hit (although that breakpoints in Register don’t do anything), and an exception is thrown on the Session[“facebookState”].ToString() part.

This is what my session-related settings in web.config look like:

<sessionState mode="InProc">
  <providers>
    <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
  </providers>
</sessionState>

I just can’t figure it out. I already rewritten the code so that it no longer produces errors and returns data from the facebook graph API, but it’s just not acceptable that I can’t debug that part of the code (for the record: breakpoints in the SingUpButton method are hit).

I hope anyone can help me out. Thanks in advance!

  • 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-06-03T16:42:56+00:00Added an answer on June 3, 2026 at 4:42 pm

    Oh god, that was stupid. Just after posting this (after looking for a solution for like 2 hours) I found out what the problem was:

    Visual Studio changed the port that my application was running on. I set that to a fixed port (right click MVC project -> web -> specific port) and now it’s working fine.

    I feel stupid now…

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

Sidebar

Related Questions

THIS PROBLEM IS NOW FIXED see updated css below. I currently have: $(form#FanDetail).serialize(), function(){
I fixed the problem below by updating the Google maps API version in this
This problem is easy fixed clientside. But for performance I want to do it
Edit : The bug that caused this problem has been fixed. The @version tag
UPDATE It looks like this problem has been quietly fixed in iOS 4.3. Up
EDITED: this first version was a false example with false assumptions! See below for
******QUESTION WAS EDITED, Please see below** I am running into a problem when I'm
I got to deep in this problem and can not see the forest out
Update: This only applies to jQuery 1.8 and below. This was fixed in jQuery
SOLVED. See below for the corrections (labeled FIXED). I'm having trouble creating a shared

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.