'Model' conflicts with the declaration 'System.Web.Mvc.WebViewPage.Model

后端 未结 2 839
迷失自我
迷失自我 2021-01-11 12:41

I have a view to Display the below Customer Object.

public Class Customer
{
    public long Id { get; set; }
    public string Name { get; set; }
    public          


        
相关标签:
2条回答
  • 2021-01-11 13:09

    The Model is of type Customer rather than of type Address in your partial. You need to change the model type in Address.cshtml to Address and change the call to the partial to pass in the AddressInfo property:

    @Html.Partial("Address", Model.AddressInfo)
    

    Your view code becomes:

    [Customer.cshtml]
    @model Customer;
    Name: @Model.Name
    Address Details: @Html.Partial("Address",Model.AddressInfo)
    
    [Address.cshtml]
    @model Address;
    @Model.CityInfo.Name, @Model.RegionInfo.Name
    
    0 讨论(0)
  • 2021-01-11 13:31

    I have resolved the issue.. Thanks for the viewers.

    The problem was In my View I was using somewhere Model => Model. Its should be model => model.

    0 讨论(0)
提交回复
热议问题