Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在app_数据文件夹中上传视频超过4MB mvc_C#_Asp.net Mvc - Fatal编程技术网

C# 在app_数据文件夹中上传视频超过4MB mvc

C# 在app_数据文件夹中上传视频超过4MB mvc,c#,asp.net-mvc,C#,Asp.net Mvc,如果(Request.Files.Count>0) { 尝试 { //从请求对象获取所有文件 HttpFileCollectionBase files=Request.files; 对于(int i=0;i

如果(Request.Files.Count>0) { 尝试 { //从请求对象获取所有文件
HttpFileCollectionBase files=Request.files; 对于(int i=0;i if(Request.Browser.Browser.ToUpper()=“IE”| Request.Browser.Browser.ToUpper()=“INTERNETEXPLORER”) { string[]testfiles=file.FileName.Split(新字符[]{'\'}); fname+=testfiles[testfiles.Length-1]; } 其他的 { fname+=file.FileName; }

                    response = new
                    {
                        status = true,
                        message = fname
                    };
                    // Get the complete folder path and store the file inside it.  
                    fname = Path.Combine(Server.MapPath("~/App_Data/ClientVideos/"), fname);
                    file.SaveAs(fname);

                }

              return  Json(response, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                response = new
                {
                    status = false,
                    message = "Error occurred. Error details: " + ex.Message
                };
                return Json(response, JsonRequestBehavior.AllowGet);                    
            }
        }

增加web.config中的
maxAllowedContentLength

<system.webServer>
   <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
   </security>
 </system.webServer>


该值以字节为单位。

更改web.config以更改最大请求大小。我使用的是IIS 10,它不起作用。它给出错误-HTTP错误500.19-内部服务器错误无法访问请求的页面,因为页面的相关配置数据无效。答案已更新,请参阅上面的重复Q以及值更改从KB转换为字节