1

I am trying to represent whether user has a valid email address in a MVC html document. It seems fairly straight forward, but I keep bumping into the same error.

Server Error in '/' Application. Cannot perform runtime binding on a null reference

Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime binding on a null reference

Source Error:

 (html document) 

Line 31:     {
Line 32:         <div>
Line 33:             <p>@string.Format(Model.User.FirstName)</p>;
Line 34:         </div>
Line 35:     }

In the 'User' model:

    /// <summary>
    /// Gets the full name.
    /// </summary>
    public string FullName
    {
        get
        {
            return string.Format("{0} {1}", this.FirstName, this.LastName);
        }
    }

In the model:

    /// <summary>
    /// Gets or sets the user.
    /// </summary>
    public User User { get; set; }

Does anyone have any ideas why this might occur?

Thankyou in advance

tereško
  • 57,247
  • 24
  • 95
  • 149
user3395937
  • 97
  • 4
  • 17

0 Answers0