Michael King
Michael King

Reputation: 638

MVC error when trying to use model in view

My problem occurs when I try to tell the view which model to use. It only happens with this model though.. Here is the model code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Com.Domain.Entities
{
    public class Components
    {

    }

    public class headerModel
    {
        public virtual String title { get; set; }
        public virtual String subtitle { get; set; }
    }
}

In the view when I try to add it like this

@model Com.Domain.Entities.headerModel;

It gives me this error:

only assignment call increment decrement and new object expressions can be used as a statement

I'm not sure what's going on. Any help would be appreciated! Thanks!

Upvotes: 2

Views: 2397

Answers (1)

ekad
ekad

Reputation: 14624

Remove ; at the end of the model declaration in your view

@model Com.Domain.Entities.headerModel

Upvotes: 9

Related Questions