1

I am working with ASP.Net and C#. I am using session state to pass the value from one page to a second. The first page calculates a value. The value is passed to the second page using session data. The second page displays the value.

I am using these two pages for facebook application.

I uploaded my two pages. When I open them with internet explorer, it gives me the error:

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

But when I open my application using firefox the pages work fine.

please help me...

outis
  • 68,704
  • 19
  • 132
  • 197
user231863
  • 11
  • 1
  • 4
  • If the problem still exist please feel free to tell me because i faced like these problems. If the problem happens in IE and other browsers so it will be because of session of facebook is gone may you are directing between pages !!! feel free to tell your problem – Ahmy Feb 08 '10 at 14:58

4 Answers4

3

It appears you are writing an IFRAME facebook application. Does it only happen in IE? if it happens with you in IE so put this code in your page that use the session :

protected override void OnPreRender(EventArgs e)
{
    Response.AppendHeader("P3P", "CP=\"CAO PSA OUR\"");
    base.OnPreRender(e);
}

See the section 'Solution to an IE gotcha when developing Facebook App in an IFRAME' on here: http://wiki.developers.facebook.com/index.php/ASP.NET

There is a problem already occurs with IE

Hope that this is useful

Ahmy
  • 5,038
  • 7
  • 37
  • 50
  • Thanks, this helped fix a problem we were seeing in similar situations. We have this in the Application_BeginRequest in other applications that need to be hosted within external iframes but it wasn't in our Facebook app. – rrrr Oct 17 '11 at 09:13
0

sessions can use URL instead of cookies. For instance, in Web.config, you can use this kind of session state configuration:

<sessionState mode="InProc" customProvider="DefaultSessionProvider" cookieless="UseUri">

Just adding P3P compact headers may lead to lawsuits if not done in the right way. Please refer to Cookie blocked/not saved in IFRAME in Internet Explorer

Community
  • 1
  • 1
benjguin
  • 1,446
  • 1
  • 12
  • 19
0

In Global.asax file add below code

   protected void Application_BeginRequest(object sender, EventArgs e)
    {
     HttpContext.Current.Response.AddHeader("p3p", "CP='CAO PSA OUR'");
    }

and web.config

<system.web>

<pages enableViewState="true" validateRequest="false" />
<httpRuntime requestValidationMode="2.0"/>
<!--
 Enable this code if you get still problem
<sessionState cookieless="true" regenerateExpiredSessionId="true" />-->

Anant Dabhi
  • 9,506
  • 2
  • 28
  • 48
0

This sounds like the session data from the first page isn't available on the second page for some reason. You're trying to pull your value from the session and perform an operation on it but the value is null, hence the NullReferenceException.

Is it possible that your Internet Explorer settings are blocking the ASP.NET session cookie? This would potentially cause the symptoms that you describe.

LukeH
  • 242,140
  • 52
  • 350
  • 400
  • where are editor when u need them ???? I don't got votes Up for my answer and this occurrs each time so i think that i will not strain myself to answer questions.... – Ahmy Dec 17 '09 at 11:08
  • @Ahmy - it would help if you used proper sentences, grammar and punctuation. Using "u" for "you" and grammatical shortcuts make your posts difficult to understand and looks unprofessional, so people are less likely to vote for them. – womp Dec 19 '09 at 23:52
  • @Womp execuse me but your reason for this problem is not reasonable !!! Each time i reply any question and the answer is helpful no evaluation inspit i took time for seraching to a solution for user problem at all i know the real reason but i will not mind or care with.... – Ahmy Dec 23 '09 at 09:32