Click here to Skip to main content
15,917,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
We have a web applications that most of users have no problem with it. But so far only few customers called when they went to the page, they got 'Object reference not set to an instance of an object', I cannot reproduce this on my computer.The error occurs only in ie8.The application was done in asp.net4.0

C#
protected void Page_Load(object sender, EventArgs e) {
            if (!IsPostBack) {
                FillStores();
                if (Session["DealType"] != null && Request.UrlReferrer.LocalPath == "/DealOptions.aspx")
                {
                    ddlCategory.SelectedIndex=ddlCategory.Items.IndexOf(ddlCategory.Items.FindByText(Session["DealType"].ToString().Replace("and", "&")));
                    DisplayLinkButton();
                }
                //else  if (Session["store"] != null)//code for back button from onlinedeal_n.aspx
                //    {
                //        ddlCategory.SelectedValue = Session["store"].ToString();
                //        DisplayLinkButton();
                //    }
                else  if (Session["ssnCategory"] != null && Request.UrlReferrer.LocalPath=="/onlinedeals4.aspx")//code for back from onlinedeal4.aspx
                    {
                        ddlCategory.SelectedValue = Session["ssnCategory"].ToString();
                        DisplayLinkButton();
                    }
                if (Session["DealType"] == null)
                {

                    FillStores();
                }
                if (Session["ssnCategory"] == null)
                {

                    FillStores();

                }

                }
            }
Posted
Updated 25-May-12 10:51am
v3
Comments
Prasad_Kulkarni 25-May-12 3:44am    
You need to provide some code snippet of what you have tried. How could one answer by just knowing this error.
Tirthankar Dutta 25-May-12 3:48am    
protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) {
FillStores();
if (Session["DealType"] != null && Request.UrlReferrer.LocalPath == "/DealOptions.aspx")
{
ddlCategory.SelectedIndex=ddlCategory.Items.IndexOf(ddlCategory.Items.FindByText(Session["DealType"].ToString().Replace("and", "&")));
DisplayLinkButton();
}
//else if (Session["store"] != null)//code for back button from onlinedeal_n.aspx
// {
// ddlCategory.SelectedValue = Session["store"].ToString();
// DisplayLinkButton();
// }
else if (Session["ssnCategory"] != null && Request.UrlReferrer.LocalPath=="/onlinedeals4.aspx")//code for back from onlinedeal4.aspx
{
ddlCategory.SelectedValue = Session["ssnCategory"].ToString();
DisplayLinkButton();
}
if (Session["DealType"] == null)
{

FillStores();
}
if (Session["ssnCategory"] == null)
{

FillStores();

}

}
}
Tirthankar Dutta 25-May-12 3:52am    
follow this link:http://support.microsoft.com/kb/810098

This error happens when you try to use a property or call a method of an object that is null. More details: here[^]

Handle all such calls/places where the error possibility is there:
1. Put null check
2. Try-catch block
 
Share this answer
 
v2
Comments
VJ Reddy 25-May-12 6:30am    
Succinct, yet elaborate 5!
Sandeep Mewara 25-May-12 15:27pm    
:)
where you are using session data before using session data check the null. and second in web config file increase the time of session expire like that :-
HTML
<system.web>
<sessionstate mode="InProc" timeout="60" />
</system.web>

and third in ie8 set the compatibility setting. i think after doing all that your problem will sort out.

best of luck.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900