By default dotnet core limits the form element count to 1024. To submit forms with more elements, increase the limit in the ConfigureServices() method of the Startup.cs file:
Tag Archives: MVC
Add identity into an ASP.NET Core 2.1 MVC project and maintain full control of the Identity UI
To maintain full control over the Identity UI in an ASP.NET Core 2.1 MVC project, scaffold the identity using the Windows version of Visual Studio 2017. Scaffold the Identity Right click the web application project and select Add, New Scaffolded Item… On the left side of the Add Scaffold dialog select Identity, and click the Add button …
Add jQuery DataTables grid to an ASP.NET Core MVC web application
ASP.NET does not provide sortable, searchable tables. jQuery DataTables is a popular way to display user-friendly data in an ASP.NET Core MVC web application. Set up the environment Add the System.Linq.Dynamic.Core NuGet package to the web application Add the JsonOptions to the Startup.cs file using Newtonsoft.Json.Serialization; Add the AddJsonOptions to the services.AddMvc() section in the ConfigureServices() method of the Startup.cs file .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver()); Add …
Continue reading “Add jQuery DataTables grid to an ASP.NET Core MVC web application”
Error unprotecting the session cookie in an ASP.NET Core MVC application.
The new ASP.NET Core MVC framework automatically displays a message for the user to accept the application’s privacy policy. The default message is “Use this space to summarize your privacy and cookie use policy.” No cookies are saved in the user’s browser until they click the Accept button. Even after accepting the terms, if the browser …
Continue reading “Error unprotecting the session cookie in an ASP.NET Core MVC application.”
Set the environment for an ASP.NET Core MVC web application
When the ASP.NET Core MVC web application starts, reads the name of the environment for an environment variable of the host computer. The compiled application contains the configuration for all supported environments, making possible to build and deploy the same artifact in every environment. If the ASPNETCORE_ENVIRONMENT environment variable is not defined, the Production environment settings are …
Continue reading “Set the environment for an ASP.NET Core MVC web application”
Return values to the controller in the model from the ASP.NET MVC view
When we create an ASP.NET MVC web application, the model (an object) is the easiest way to return values from the view to the controller. For the view to be able to return the values in the model, make sure the model contains properties, not fields, for every value with { get; set; } public class MyViewModel { public …
Continue reading “Return values to the controller in the model from the ASP.NET MVC view”
Block comment in ASP.NET MVC Razor file
To comment out a block of lines in the ASP.NET MVC Razor file, enclose them in @* and *@ @* Commented out instructions, including HTML and Extension methods *@
The .NET MVC model has to have a parameterless constructor
When you create a class to be used as the model in a .NET MVC application, the class has to have a parameterless constructor. It is called during the POST when the user clicks the submit button of the form. If the class does not have a parameterless constructor, we will get the following generic …
Continue reading “The .NET MVC model has to have a parameterless constructor”
There is already an open DataReader associated with this Command which must be closed first
When your MVC 5 web application page tries to read the database using the Entity Framework in a loop you may get the following error message: InnerException: System.InvalidOperationException HResult=-2146233079 Message=There is already an open DataReader associated with this Command which must be closed first. Source=System.Data This usually happens when a cshtml page receives an IEnumerable<> …