- Notifications
You must be signed in to change notification settings - Fork 2.1k
Wrong name and id in input after upgrade to ASP Core 1.1.0 #5655
Description
Hi all,
I’ve upgraded our ASP Core 1.0.1 solution to ASP Core 1.1. We hit an issue with one of our pages after the upgrade. We have the following code in razor:
@for (var i = 0; i < Model.ContactPersons.Count(); i++) { <tr> <th > <input asp-for="@Model.ContactPersons[i].Name" /> <span asp-validation-for="@Model.ContactPersons[i].Name" class="text-danger"></span> </th> <th > <input asp-for="@Model.ContactPersons[i].PhoneNumber" /> <span asp-validation-for="@Model.ContactPersons[i].PhoneNumber" class="text-danger" style=""></span> </th> </tr> } This code result in 1.0.1 into the following HTML:
<tr> <td> <input type="text" data-val="true" data-val-required="The Name field is required." id="ContactPersons_0__Name" name="ContactPersons[0].Name" value="" /> <span class="text-danger field-validation-valid" data-valmsg-for="ContactPersons[0].Name" data-valmsg-replace="true"></span> </td> <td> <input type="tel" data-val="true" (...) id="ContactPersons_0__PhoneNumber" name="ContactPersons[0].PhoneNumber" value="" /> <span class="text-danger field-validation-valid" style="" data-valmsg-for="ContactPersons[0].PhoneNumber" data-valmsg-replace="true"></span> </td> </tr> This worked great until we upgraded to ASP Core 1.1.0. The razor code above now results into the following HTML:
<tr> <td > <input type="text" data-val="true" data-val-required="The Name field is required." id="Name" name="Name" value="" /> <span class="text-danger field-validation-valid" data-valmsg-for="Name" data-valmsg-replace="true"></span> </td> <td> <input type="tel" data-val="true" (...) id="PhoneNumber" name="PhoneNumber" value="" /> <span class="text-danger field-validation-valid" style="" data-valmsg-for="PhoneNumber" data-valmsg-replace="true"></span> </td> </tr> Please pay attention to the ‘name’ and ‘id’ properties of the input fields. Not having the ‘_{id}__’ layout results in zero items in the list upon submit.
We have been able to narrow the issues down to the following package: Microsoft.AspNetCore.Mvc. When having version 1.0.1 the page is working, but having version 1.1.0 it kills our submit in the page.
Is this a bug?
Thanks!
Rick
For completeness this is the complete project.json file we have:
{ "buildOptions": { "emitEntryPoint": true, "preserveCompilationContext": true }, "configurations": { "iOS": {} }, "dependencies": { "Microsoft.NETCore.App": { "version": "1.1.0", "type": "platform" }, "MasterData": "1.0.0-*", "CountModels": "1.0.0-*", "WindowsAzure.Storage": "8.0.0", "Swashbuckle": "6.0.0-beta902", "SyncFusion.EJ.AspNet.Core": "14.4600.0.15-preview2-final", "Syncfusion.Compression.AspNet.Core": "14.4600.0.15-preview2-final", "Syncfusion.DocIO.AspNet.Core": "14.4600.0.15-preview2-final", "Syncfusion.XlsIO.AspNet.Core": "14.4600.0.15-preview2-final", "Microsoft.ApplicationInsights.AspNetCore": "1.0.2", "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0", "Microsoft.Extensions.Logging.Console": "1.1.0", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0", "System.ComponentModel.Annotations": "4.3.0", "Microsoft.AspNetCore.Authentication.JwtBearer": "1.1.0", "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0", "Microsoft.AspNetCore.Diagnostics": "1.1.0", "Microsoft.AspNetCore.Mvc": "1.0.1", "Microsoft.AspNetCore.Mvc.Versioning": "1.0.3", "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final", "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0", "Microsoft.AspNetCore.Server.Kestrel": "1.1.0", "Microsoft.AspNetCore.StaticFiles": "1.1.0", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0", "Microsoft.Extensions.Configuration.Json": "1.1.0", "Newtonsoft.Json": "9.0.2-beta1", "bootstrap": "4.0.0-alpha5", "Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final" }, "frameworks": { "netcoreapp1.1": { "dependencies": {}, "imports": [ "dotnet5.6", "portable-net45+win8" ] } }, "publishOptions": { "include": [ "wwwroot", "web.config", "Views", "appsettings.json" ] }, "runtimeOptions": { "configProperties": { "System.GC.Server": true } }, "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final" }, "scripts": { "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] }, }