System.NullReferenceException in App_Web_*.dll

前端 未结 1 1154
鱼传尺愫
鱼传尺愫 2020-12-15 17:46

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

相关标签:
1条回答
  • 2020-12-15 18:17

    I found the answer to my problem here

    For anyone finding this:

    Try commenting out the next code line AFTER the error.

    @ModelType CheckImHereMVC.OrganizationEditViewModel
    
    @Using Html.BeginForm("Edit", "Organization", FormMethod.Post)
       @Html.AntiForgeryToken() 
       @Html.ValidationSummary(True) 
       @Html.TextBoxFor(Function(model) model.organizationSub.subName, New With {.class = "span12"})
       @Html.TextBoxFor(Function(model) model.organizationSub.subTitle, New With {.class = "span12"})
       <img src="@Url.Content(Model.img.imgPath)" alt="IMAGES"/> 'commenting out this line fixed my issue
    End Using
    

    In the case above, i would get errors on the model.organizationSub.subTitle. If i commented that line out, i would get errors on the model.organizationSub.subName line. I then found the link mentioned and commented out the line AFTER all of my TextBoxFors. That fixed my issue.

    From link: "Some times compiler could not point on exact lines having specific kind of errors in razor view may be because it could not keep their line number in stack trace or somewhere. I have found this case with Null Reference Exception and when null is passed in Url.Content.

    So it helps to check the next C# statement in razor view when you did not get any error on the line shown by stack trace."

    0 讨论(0)
提交回复
热议问题