I am having an odd issue.
My MVC application seems to be working perfectly fine except for one view page.
The view page in question (Organization/Edit) gets a 'NullReferenceException' on every code item on the page. Whether it is Html.TextBoxFor() or HTML.AntiForgeryToken().
I have my model, view, and controller laid out here on another question that i think is related -- https://stackoverflow.com/questions/26475866/dropdownlistfor-null-reference-error
As you can see below, my model does have information inside of it. This screen capture was taken at the "Return View("Edit", model)" inside the controller.
Exception Details
- Source = App_Web_zu4jlld0
- StackTrace = at ASP._Page_Views_Organization_Edit_vbhtml.Execute() in C:UsersmtaylorProjectsCheck Im Heremtaylor-branchCheckImHere_v2CheckImHereMVCViewsOrganizationEdit.vbhtml:line 16
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
at System.Web.WebPages.StartPage.RunPage()
at System.Web.WebPages.StartPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
View
@ModelType CheckImHereMVC.OrganizationEditViewModel
@Using Html.BeginForm("Edit", "Organization", FormMethod.Post)
@Html.AntiForgeryToken() 'get errors here
@Html.ValidationSummary(True) 'get errors here
@Html.TextBoxFor(Function(model) model.organizationSub.subName, New With {.class = "span12"}) 'and errors here
End Using
One thing i notice is that if i comment out my 'textboxfor', my error will occur at the 'ValidationSummary()', if i comment out my 'ValidationSummary()', then my error will occur at 'AntiForgeryToken()'.
So it seems that the error just happens at the last possible code area.
See Question&Answers more detail:os