Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
726 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...