Home kellton

Main navigation

  • Services
    • Digital Business Services
      • AI Services
        • Generative Al Services
        • Agentic Al & Automation
        • Traditional Al Solutions
        • Al Engineering & Platforms
        • Al Governance & Risk
        • Data Engineering for Al
      • Digital Experience
        • Product Strategy & Consulting
        • Product Design
        • Product Management
      • Product Engineering
        • Digital Application Development
        • Mobile Engineering
        • IoT & Wearables Solutions
        • Quality Engineering
      • Data & Analytics
        • Data Consulting
        • Data Engineering
        • Data Migration & Modernization
        • Analytics Services
        • Integration & API
      • Cloud Engineering
        • Cloud Consulting
        • Cloud Migration
        • Cloud Managed Services
        • DevSecOps
      • NextGen Services
        • Blockchain
        • Web3
        • Metaverse
        • Digital Signage Solutions
        • Spatial Computing
    • SAP Hide
      • ServiceNow
        • AI Solutions
        • Implementation Services
        • Optimization Services
        • Consulting Services
      • SAP
        • S/4HANA Implementations
        • SAP AMS Support
        • SAP Automation
        • SAP Security & GRC
        • SAP Value Added Solutions
        • Other SAP Implementations
      • View All Services
  • Platforms & Products
    • Hooper
    • Structi.ai
    • Optima
    • KAI SDLC 360
    • tHRive
    • Audit.io
    • Kellton4Commerce
    • Kellton4NFT
    • Our Data Accelerators
      • Digital DataTwin
      • SmartScope
      • DataLift
      • SchemaLift
      • Reconcile360
    • View All Products
  • Industries
    • Fintech, Banking, Financial Services & Insurance
    • Retail, E-Commerce & Distribution
    • Pharma, Healthcare & Life Sciences
    • Non-Profit, Government & Education
    • Travel, Logistics & Hospitality
    • HiTech, SaaS, ISV & Communications
    • Manufacturing, Automotive & Chemicals
    • Oil,Gas & Mining
    • Energy & Utilities
    • View All Industries
  • Our Partners
    • ServiceNow
    • Microsoft
    • AWS
    • SAP
    • View All Partners
  • Insights
    • Blogs
    • Brochures
    • Success Stories
    • News / Announcements
    • Webinars
    • White Papers
  • Careers
    • Job
    • Life At Kellton
  • About
    • About Us
    • Our Leadership
    • Testimonials
    • Analyst Recognitions
    • Investors
    • Privacy-Policy
    • Contact Us
    • Our Delivery Centers
      • India Delivery Center
      • Europe Delivery Center
Search
  1. Home
  2. All Insights
  3. Blogs

How to submit a large number of Form-values in ASP.NET Core?

Product Engineering
Published On: November 16 , 2017
Updated On: July 13, 2023
Posted By:
Kellton
linkedin
4 min read
How to Submit a Large Number of Form-values in ASP.NET Core

Other recent blogs

What ServiceNow Knowledge
What ServiceNow Knowledge 2026 Revealed About Agentic AI
July 17 , 2026
Documents as Data
Documents as Data: Eliminating Unstructured Legal Text Burden
July 10 , 2026
SAP Service Cloud: Revolutionizing Customer Experience in Banking
SAP Service Cloud: Revolutionizing Customer Experience in Banking
July 03 , 2026

Let's talk

Reach out, we'd love to hear from you!

CAPTCHA
Image CAPTCHA
Get new captcha!
Enter the characters shown in the image.

HTML forms use either GET or POST method to submit form values to the server. The default method that most of the developers use is GET. When using the GET method, the form data is encoded in the URI as a query string. However, when using the POST method, the form data is placed in the request body.

If you wish to submit a form with a large number of elements (say 500 checkboxes) to our controller post method, then we get a runtime exception: InvalidDataException: Form value count limit 1024 exceeded. This exception means that ASP.NET Core does not allow us to post data which have value and key length above 1024. In order for the developer to explicitly enable this, we can use the following two ways:

  1. Application Level Changes:  Add the code in the startup.cs file as it will apply by default to all controller methods in the application.

    public void ConfigureServices(IServiceCollection services)
    { 
    services.Configure<FormOptions>(x => x.ValueCountLimit = 10000);
    services.AddMvc();
    }
  2. Method Level Changes: To increase the form size limit at the method level, we need to create a custom attribute say “RequestFormSizeLimitAttribute” in the controller post method.

  public class RequestFormSizeLimitAttribute : Attribute, IAuthorizationFilter,    

       IOrderedFilter

    {

        private readonly FormOptions _formOptions;

        public RequestFormSizeLimitAttribute(int valueCountLimit)

        {

            _formOptions = new FormOptions()

            {

                ValueCountLimit = valueCountLimit

            };

        }

        public int Order { get; set; }

        public void OnAuthorization(AuthorizationFilterContext context)

        {

            var features = context.HttpContext.Features;

            var formFeature = features.Get<IFormFeature>();

            if (formFeature == null || formFeature.Form == null)

            {

                features.Set<IFormFeature>(new FormFeature(context.HttpContext.Request,      

                _formOptions));

            }

        }

   }

Once the attribute is ready, we need to increase the key length which can be done in the following two ways:

  1. If no “Antiforgery” token is applied to the controller method, then the attribute can be applied directly on the method without specifying “order” of execution.

    [HttpPost]
    [RequestFormSizeLimit(valueCountLimit: 20000)]
    public IActionResult ActionSpecificLimits(YourModel model)
     
  2. If “Antiforgery” token is applied to the controller method, then we need to specify the order in which the attributes will be executed. If the order is not mentioned then the following exception is raised: “InvalidDataException: Form value count limit 1024 exceeded.”

It is mandatory to execute the “RequestFormSizeLimitAttribute” attribute before the “Antiforgery” token validation filter so that the limits are honored when the antiforgery validation filter tries to read the form. The form size limits only apply to this action.

[HttpPost]
[RequestFormSizeLimit(valueCountLimit: 20000, Order = 1)]
[ValidateAntiForgeryToken(Order = 2)]
public IActionResult ActionSpecificLimits(YourModel model)

LearnMore.jpg

Digital Transformation comprises the largest portfolio of work for Kellton Tech. Learn more about how our digital expertise is increasing ROI of clients looking for.NET Development Services.

Want to know more?

Serverless Computing 101: Building Scalable Apps Without Infrastructure Headaches
Blog
Serverless Computing 101: Building Scalable Apps Without Infrastructure Headaches
June 18 , 2026
DevOps Maturity Model: How to Achieve Continuous Delivery and Innovation
Blog
DevOps Maturity Model: How to Achieve Continuous Delivery and Innovation
June 02 , 2026
AI-led legacy modernization
Blog
How systematic refactoring works as a product engineering framework for deep legacy modernization?
May 18 , 2026

North America: +1.844.469.8900

Asia: +91.124.469.8900

Europe: +44.203.807.6911

Email: ask@kellton.com

Footer menu right

  • Services
  • Platforms & Products
  • Industries
  • Insights

Footer Menu Left

  • About
  • News
  • Careers
  • Contact
LinkedIn Twitter Youtube Facebook
clutch Badge
Chatbot
Kellton Kellton Assistant

Feel free to inquire about any Digital Transformation Initiative

Hi there! Welcome to Kellton! It's great to have you here. How can I assist you today?

© 2024 Kellton