1

Basically its a get method .when the function hit first time it simply return the view of login page after that when i set session value,after that in post back request it give me an exception object instance

var sessionvar = System.Web.HttpContext.Current.Session["EmployeeName"].ToString();

        if (!String.IsNullOrWhiteSpace(sessionvar)) 
        {
            return RedirectToAction("ViewWareHouseList", "Inventary");
        }
        return View();
    }
usman
  • 134
  • 6
  • You should use `as` operator if `Session["EmployeeName"]` contains null value: `if (!String.IsNullOrWhiteSpace(System.Web.HttpContext.Current.Session["EmployeeName"] as string))`. – Tetsuya Yamamoto Nov 14 '18 at 09:49
  • 2
    Possible duplicate of [Testing a session variable for null or empty space](https://stackoverflow.com/questions/41989625/testing-a-session-variable-for-null-or-empty-space) – Tetsuya Yamamoto Nov 14 '18 at 09:50

0 Answers0