I am trying to get session value in mvc5 razor as below
@{var cnt=Session["count"].ToString();}
@if (cnt == "0" || string.IsNullOrWhiteSpace(cnt))
This results in an error if there is no value for session. How should this be checked
I am trying to get session value in mvc5 razor as below
@{var cnt=Session["count"].ToString();}
@if (cnt == "0" || string.IsNullOrWhiteSpace(cnt))
This results in an error if there is no value for session. How should this be checked
Simply check if its null
@if (Session["count"] != null) {
//Do what you want
}