Compiler Error Message: CS0135: 'Model' conflicts with the declaration 'System.Web.Mvc.WebViewPage.Model'

前端 未结 2 1925
青春惊慌失措
青春惊慌失措 2020-12-11 02:59

I am using ASP.NET MVC 3. I have created a strongly typed view that has a form. At the bottom of the page I have and ActionLink

  @Html.ActionLink(\"Edit\",         


        
相关标签:
2条回答
  • 2020-12-11 03:24

    I found simply replacing the capital M with a small m solved this. i.e. from

    @Html.TextBoxFor(Model => Model.SomeProperty)
    

    to

    @Html.TextBoxFor(model => model.SomeProperty)
    

    Perhaps it is more ambiguous, but it is less of a change if you want to keep things similar to the way they were.

    0 讨论(0)
  • 2020-12-11 03:29

    I guess somewhere in your view you have used a strongly typed helper with a lambda expression using the reserved Model keyword. Like for example:

    @Html.TextBoxFor(Model => Model.SomeProperty)
    

    it should be:

    @Html.TextBoxFor(x => x.SomeProperty)
    

    or any other name.

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