Server Error in '/' Application.

Cannot convert null to 'int' because it is a non-nullable value type

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot convert null to 'int' because it is a non-nullable value type

Source Error:


Line 4:  		<ul class="styled">
Line 5:          @{       
Line 6:              int parentID = ViewBag.ParentCategoryID;
Line 7:              int currentID = ViewBag.CategoryID;               
Line 8:              var currentCategory = DB.CreateEntities().Express_NewsCategory.SingleOrDefault(m => m.ID == currentID);

Source File: c:\wwwnewdays\Views\News\LeftPanel.cshtml    Line: 6

Stack Trace:


[RuntimeBinderException: Cannot convert null to 'int' because it is a non-nullable value type]
   CallSite.Target(Closure , CallSite , Object ) +148
   System.Dynamic.UpdateDelegates.UpdateAndExecute1(CallSite site, T0 arg0) +244
   ASP._Page_Views_News_LeftPanel_cshtml.Execute() in c:\wwwnewdays\Views\News\LeftPanel.cshtml:6
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +255
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +124
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +123
   System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper htmlHelper, String partialViewName) +99
   ASP._Page_Views_News_Category_cshtml.Execute() in c:\wwwnewdays\Views\News\Category.cshtml:17
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +255
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +124
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +88
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +108
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +378
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +31
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +448
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +659
   System.Web.Mvc.Controller.ExecuteCore() +147
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +92
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +60
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +25
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +36
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +431
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +75
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +158


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4676.0