ASP.net - Safe method to check session is null
Robust application has to utilize Proper method to check the session veribles.Following method is one of the best approch. Assume Session["selmachine_id"] hold string value string sessionMac = Session["selmachine_id"] as string; if (!string.IsNullOrEmpty(sessonTestId)) { //Valid Action }