title: Form key or value length limit 2048 exceeded
body: <p>I am using asp.net core to build API. I have a request that allow user to upload profile image using this code</p>
  
  <pre><code> [HttpPost("{company_id}/updateLogo")]
          public async Task&lt;IActionResult&gt; updateCompanyLogo(IFormFile imgfile,int company_id)
          {
              string imageName;
              // upload file
              if (imgfile == null || imgfile.Length == 0)
                  imageName = "default-logo.jpg";
              else
              {
                  imageName = Guid.NewGuid() + imgfile.FileName;
                  var path = _hostingEnvironment.WebRootPath + $@"\Imgs\{imageName}";
                  if (imgfile.ContentType.ToLower().Contains("image"))
                  {
                      using (var fileStream = new FileStream(path, FileMode.Create))
                      {
                          await imgfile.CopyToAsync(fileStream);
                      }
                  }
              }
  .
  .
  </code></pre>
  
  <p>but it keeps returning this exception: <code>Form key or value length limit 2048 exceeded</code><br>
  <strong>The Request</strong> <br>
  <a href="https://i.imgur.com/25B0qkD.png" rel="noreferrer">http://i.imgur.com/25B0qkD.png</a><br></p>
  
  <p><strong>Update:</strong><br>
  I have tried this code but it doesn't work</p>
  
  <pre><code>    services.Configure&lt;FormOptions&gt;(options =&gt;
      {
          options.ValueLengthLimit = int.MaxValue; //not recommended value
          options.MultipartBodyLengthLimit = long.MaxValue; //not recommended value
      });
  </code></pre>