开发者

asp.net session error

开发者 https://www.devze.com 2022-12-14 05:15 出处:网络
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. Th

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.

Des开发者_JAVA技巧cription: 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...


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


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.


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


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" />-->

0

精彩评论

暂无评论...
验证码 换一张
取 消