Ajax将大型base64字符串发布到Web Api失败

Ajax将大型base64字符串发布到Web Api失败,ajax,asp.net-web-api,Ajax,Asp.net Web Api,我向包含base64编码字符串和一些其他数据对象的控制器发送一篇ajax文章。 现在,我有一个简单的控制器,可以将静态图像写入文件夹 代码如下 [System.Web.Http.Route("api/Assessment/saveLvlTAssessment1")] [System.Web.Http.HttpPost] [EnableCors("*", "*", "*")] public HttpResponseMessage SaveAsse

我向包含base64编码字符串和一些其他数据对象的控制器发送一篇ajax文章。 现在,我有一个简单的控制器,可以将静态图像写入文件夹

代码如下

  [System.Web.Http.Route("api/Assessment/saveLvlTAssessment1")]
        [System.Web.Http.HttpPost]
        [EnableCors("*", "*", "*")]
        public HttpResponseMessage SaveAssessment1([FromBody] MobileLvlTAssessmentModel model)
        {
            var response = new HttpResponseMessage();
            String path = System.Web.Hosting.HostingEnvironment.MapPath(WebConfigurationManager.AppSettings["ImagePath"]); //Path
            string image = model.Image;
            try
            {
                string fileName = path + "/Test#@@#.jpg";

                byte[] imageBytes = Convert.FromBase64String(image);
                using (FileStream
                    fileStream = new FileStream(fileName, FileMode.Create))
                {
                    // Write the data to the file, byte by byte.
                    for (int i = 0; i < imageBytes.Length; i++)
                    {
                        fileStream.WriteByte(imageBytes[i]);
                    }

                    // Set the stream position to the beginning of the file.
                    fileStream.Seek(0, SeekOrigin.Begin);
                }
            }


            catch (Exception ex)
            {
                response = Request.CreateResponse(HttpStatusCode.Accepted, ex.ToString());
                throw ex;
            }

            if (response.Content == null)
            {
                response = Request.CreateResponse(HttpStatusCode.Accepted, "Saved");
            }
            return response;
        }
我已将此添加到我的web.config

<security>
      <requestFiltering>
    <requestLimits maxAllowedContentLength="10485760" />
      </requestFiltering>
            <authentication>
                <anonymousAuthentication userName="dot\achatterjee" password="[enc:AesProvider:ojOlpPI0WUJNmGMlrVoBzBqwj4XpXW8cX2vVI9KY5QZLLOfxJ/inyx8ZR6fVSo5S:enc]" />
                <windowsAuthentication enabled="false" />
            </authentication>
    </security>
我的post请求在远程服务器中始终失败。但是,如果我不发送图像数据,它就会通过

这件事已经讨论了好几个小时了,如果有任何想法或提示,我将不胜感激

<security>
      <requestFiltering>
    <requestLimits maxAllowedContentLength="10485760" />
      </requestFiltering>
            <authentication>
                <anonymousAuthentication userName="dot\achatterjee" password="[enc:AesProvider:ojOlpPI0WUJNmGMlrVoBzBqwj4XpXW8cX2vVI9KY5QZLLOfxJ/inyx8ZR6fVSo5S:enc]" />
                <windowsAuthentication enabled="false" />
            </authentication>
    </security>
GlobalConfiguration.Configuration.Formatters.FormUrlEncodedFormatter.ReadBufferSize = 256 * 1024; // 256 KB