Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
712 views
in Technique[技术] by (71.8m points)

c# - 'Model' conflicts with the declaration 'System.Web.Mvc.WebViewPage<TModel>.Model

I have a view to Display the below Customer Object.

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

public class Address 
{
    public string Details { get; set; }
    public City CityInfo { get; set; }
    public Region RegionInfo { get; set; }
}

And Having an Controller to return the Customer to View

public ActionResult GetCustomer(long Id)
{
    return View("Customer",GetCustomer(Id));
}

And finally the View Is,

[Customer.cshtml]
@model Customer;
Name: @Model.Name
Address Details: @Html.Partial("Address",Model)

[Address.cshtml]
@model Customer;
@Model.CityInfo.Name, @Model.RegionInfo.Name

All seems fine. But I am getting "'Model' conflicts with the declaration 'System.Web.Mvc.WebViewPage.Model" error on @Html.Partial("Address",Model) I had done the same before in many projects and did not got the problem.

I have no clue of further proceeding.

Could someone please help me to resolve this issue.

I have seen many posts regarding this kind of error. But those were not with the @Html.Partial().

Thanks & Regards,

Saravanakumar R.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...