0

I am using .NET Core MVC. In the .cshtml page, I am using the data from the model but when the data is null, I am getting the error below. I want to set a blank (" ") value if a null or empty value comes from the model. How can I do that?

enter image description here

@(Model.Username == null ? "" : Model.Username)

I try that but it didn't work.

  • 1
    If the lins of code shown is throwing the error then that implies `Model` is `null`, not the `Username` property. – David Feb 21 '23 at 15:26

0 Answers0