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 panditPosted Nov 29, 2018, 8:43 AM
Jignesh KumarPosted Nov 27, 2018, 11:37 PM
Sagar MaldePosted Nov 27, 2018, 11:05 PM
- 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 usemayur panditPosted Nov 27, 2018, 9:14 PM
Jignesh KumarPosted Nov 27, 2018, 10:04 AM
mayur panditPosted Nov 27, 2018, 9:33 AM