Can someone help me figure out if what I'm attempting in asp.net is feasible? I'm encountering an issue that I could use some expertise on. :)
Within my HTML
view, I am fetching values from the session and assigning them to select list items.
However, there are instances when the session data is unavailable and when a user attempts to refresh the Index page, I encounter the error:
'There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'MyBranch
.
So my objective here is to check if this returns null and if so, redirect to
Action = Logoff, Controller = Account
.
This is what I have attempted in my view:
List<SelectListItem> MyBranch = Session["MyBranch"] as List<SelectListItem>;
if (MyBranch == null)
{
// I need guidance on how to redirect to this action
}
Any suggestions or solutions?