getting below error :
An exception of type 'System.NullReferenceException' occurred in App_Code.xdxzpwdw.dll but was not handled in user code
Additional information: Object reference not set to an instance of an object.
description :
below code working fine in other classes but in one class session becommig null automatically.
I am passing post request using ajax and uploading image and deleting image also same time.
Kindly check below code. I did not understand why this problem is occuringexatly. Kindly help.
code details :
public object BL_product_InsertUpdate(tbl_product product)//BL_admin_userInsertUpdate
{
string message = string.Empty;
if (!string.IsNullOrEmpty(HttpContext.Current.Session["UserName"].ToString()))
{
}
}


mayur panditRank #4,868 · 321 reputationPosted Nov 29, 2018, 3:43 AM EST
mayur panditRank #4,868 · 321 reputationPosted Nov 27, 2018, 4:33 AM EST
Jignesh KumarRank #91 · 22.9K reputationPosted Nov 27, 2018, 5:04 AM EST
mayur panditRank #4,868 · 321 reputationPosted Nov 27, 2018, 4:14 PM EST
Sagar MaldeRank #2,097 · 684 reputationPosted Nov 27, 2018, 6:05 PM EST
- The Default timeout for Session is of 20 minutes. Thus after 20 minutes the Session automatically becomes null
- In your code you are using .toString() extension method which does not except null values. This extension is throwing the null reference error.
However if you want to ignore session value you can useJignesh KumarRank #91 · 22.9K reputationPosted Nov 27, 2018, 6:37 PM EST