I am having problems accessing one of the properties of the model I am passing a View.

The model is defined like this:

public class ProductBasket
{
    public ProductBasket()
    {
        Products = new List<ProductConfiguration>();
        Errors = new List<string>();
    }
    public List<ProductConfiguration> Products { get; set; }
    public List<string> Errors { get; set; }
}

In my view the model directive is declared like this:

@model MyApp.ViewModels.Product.ProductBasket

I am unable to access the Products property in a foreach loop. In VisualStudio when I hover of the Model variable in the loop it shows:

List<MyApp.ViewModels.Product.ProductConfiguration> 
WebViewPage<List<MyApp.ViewModels.Product.ProductConfiguration>>.Model { get; }

This is the previous model I was using - I don't know why this is there?

What I have done

Instinct tells me I should be able to access the Products property with Model.Products (please tell me if this is incorrect), but I don't understand why the view isn't being passed a ProductBasket?

Related posts

Recent Viewed