I have a hidden field that renders an integer siteId defined in my viewbag
Sometimes this is not present im assuming it may be related to sessions in MVC
When this happens how can I redirect to my login page? At present this is coming up with a cast error in my cshtml page
If the error happened in my controller it’s easy but I don’t know how to deal with errors in cshtml files
My cshtml has this
<div>
@(Html.Hidden("SiteID", (int) ViewBag.SiteID))
</div>
It appears as though if my user stays on the site for a while then tries to refresh or do something else I get cannot convert null to 'int' because it is a non nullable type
Paul