Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.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
Asp.net 上传附件-限制文件大小-IE无法显示网页_Asp.net_File Upload - Fatal编程技术网

Asp.net 上传附件-限制文件大小-IE无法显示网页

Asp.net 上传附件-限制文件大小-IE无法显示网页,asp.net,file-upload,Asp.net,File Upload,我正在尝试测试,看看如果我上传的文件大小超过3mb,是否会出现错误,但我得到的是IE错误,请参见下文 这是我的密码我想要的是,如果用户试图上传超过3mb的文件大小,则显示一个错误 if (fUpload.HasFile) { // Get the size in bytes of the file to upload. int fileSize = fUpload.PostedFile.ContentLength; // Allow only file

我正在尝试测试,看看如果我上传的文件大小超过3mb,是否会出现错误,但我得到的是IE错误,请参见下文

这是我的密码我想要的是,如果用户试图上传超过3mb的文件大小,则显示一个错误

 if (fUpload.HasFile)
 {
   // Get the size in bytes of the file to upload.            
   int fileSize = fUpload.PostedFile.ContentLength;
  // Allow only files less than 3145728 bytes (approximately 3 MB) to be uploaded.
  if (fileSize > 3145728) //if (fUpload.PostedFile.ContentLength <= 3072) 
  {
     ..............
     .............
  }
  else
  {
    // Notify the user why their file was not uploaded.                
    this.lblStatus.Text = "Your file was not uploaded because it exceeds the 3 MB size limit.";
  }
}

<system.web>
    <httpRuntime maxRequestLength="3145728" />


Internet Explorer cannot display the webpage
This problem can be caused by a variety of issues, including: 

•Internet connectivity has been lost.
•The website is temporarily unavailable.
•The Domain Name Server (DNS) is not reachable.
•The Domain Name Server (DNS) does not have a listing for the website's domain.
•There might be a typing error in the address.
•If this is an HTTPS (secure) address, click Tools, click Internet Options, click Advanced, and check to be sure the SSL and TLS protocols are enabled under the security section.

您正在服务器端执行此操作。这意味着文件已经开始上载到服务器。我也找不到解决方案,也不知道是否有解决此问题的方法。

以下是我如何解决此问题的方法:

默认情况下,您应该能够上传高达4MB的文件,并且MaxRequestLength以KB为单位。所以,默认值是4096KB。如果您尝试上载大小超过4MB的文件,则会出现错误。因此,将其增加到大约25Mb或一个较大的数字。然后您应该能够跟踪代码中的文件大小

<httpRuntime maxRequestLength="2097151" executionTimeout="3600"/>

你能把它封装在一个try-catch块中并试着调试这个问题吗?我在事件开始时有一个断点,但它从来没有出现过,所以它甚至没有执行代码,只是重定向到我上面发布的IE错误。是的,它通过回发启动上载,如果文件大于maxRequestLength,则在您检查文件大小之前会发生错误。在不执行代码的情况下,它将如何开始上载?我有断点,但它从来没有中断过。它适用于小文件,但对于大文件,它甚至没有执行代码。它只是显示ie错误:……奇怪