Closed boyandim closed 6 years ago
Thanks for contacting us, @boyandim. @dougbu, can you please look into this? Thanks!
In MVC5 the same setup will render an input element with name attribute "ShipName" without the Order
This is surprising because MVC 5 has similar logic to ASP.NET Core around mapping Linq expressions to expression names. Do you have a sample showing MVC 5 behaving as you describe? If yes, I would appreciate a minimal repro project that illustrates the problem, preferably hosted in a GitHub repo.
Hi. We're closing this issue as there's been no response and we have been unable to reproduce it. If you have more details and are encountering this issue please add a new reply and re-open the issue.
We do have the following model structure:
In the HomeController we send an instance of the HomePageModel to the Index view.
In the Index view we use a partial view and send just the OrderViewModel using the Order property of the HomePageModel to partial view:
@{ ViewData["Title"] = "Home Page"; }
@model AspNetCoreApp28.Models.HomePageModel
The partial view contains one EditorFor helper for the string ShipName
@(Html.EditorFor(m => m.ShipName))
The result of rendering is an input element with a name attribute name="Order.ShipName" instead of just "ShipName".
In MVC5 the same setup will render an input element with name attribute "ShipName" without the Order, which in my case works fine with my MVVM logic. Is there any way in ASP.NET Core MVC to avoid rendering "Order" in the name attribute of the input element?