CS0119 – Cannot Reference ViewModel in ASP.NET MVC

  Kiến thức lập trình

I’m referencing a View Model – the HistoryVM class – like so in a .cshtml file:

@model PaidWeb.ViewModels.HistoryVM;

For some reason, when trying to reference the new view model I just created, the .cshtml file is showing a CS0119 error which reads: “HistoryVM is a type which is not valid in the given context”.

The HistoryVM is defined as such:

    public class HistoryVM
    {
        public List<DAL.Transfer> TransfersIn { get; set; }
        public List<DAL.Transfer> TransfersOut { get; set; }
    }

I don’t see what the issue is. This is the correct syntax as far as I’m concerned.
Not sure what the problem is.

Could someone please chime in to get this resolved?

Thanks.

1

LEAVE A COMMENT