I recently converted my App to use Session State "SQL Sever" instead of "InProc" as I had to do some redirects to a third-party app. Everything is working ok and I can set and retrieve session values easily. The problem occurs when I try to access the Session again from a different Controller method
This is how it is structured:
Add Company Method
public String AddNewCompany()
{
SalesInvoiceSettingController invoiceSetting = new SalesInvoiceSettingController();
string Uname = Session["UserName"].ToString(); // This session value is picked correctly
invoiceSetting.SaveInvoiceSettings(); // This is another method which I am calling inside this method, by creating an object of 'SalesInvoiceSettingController'
The SaveInvoiceSettings Method
public string SaveInvoiceSettings()
{
string Uname = Session["UserName"].ToString(); <-- This is where I get a NULL POINTER EXCEPTION i.e Object Reference not set to an instance of an object.
Not sure what i am doing wrong here? it`s accessible from a method of one controller but not from a method of a different controller. Can anyone help me on this?