You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows Form站点大文件入库慢及HTTP Error 404.13问题求助

Hey Rick, let's walk through each of the issues you're hitting with your Web Forms file upload + GridView workflow—since this is your first time building something like this, I'll keep the fixes straightforward and focused on what you need right now:

1. 分页开启时只能插入显示的前10条数据

This is a super common gotcha with GridView pagination! When pagination is turned on, the GridView only renders the current page's rows (your 10 entries) on the client side, and the server only has access to those rows in GridView.Rows during postback. That's why you can't insert all your uploaded files—you're only grabbing what's visible.

Fixes:

  • Store all upload data outside the GridView: When users upload files, save the full list of file details (filename, upload path, approval status, etc.) to a Session object or a temporary database table instead of relying solely on the GridView. For example:
    // When uploading, add to a session-stored list
    var uploadedFiles = Session["UploadedFiles"] as List<FileUploadRecord> ?? new List<FileUploadRecord>();
    uploadedFiles.Add(new FileUploadRecord { 
        FileName = uploadedFile.FileName, 
        FilePath = serverFilePath, 
        IsApproved = false 
    });
    Session["UploadedFiles"] = uploadedFiles;
    
  • Update approval status in the stored list: When users mark rows as approved in the GridView, update the corresponding entry in your Session/temp table instead of just the GridView row.
  • Use the stored list for insertion: When clicking "入库", iterate over the full list from Session/temp table, filter for approved entries, and insert those into your main database table. This way you don't miss any records, even if they're on a different GridView page.
2. 关闭分页插入时出现HTTP Error 404.13

The 404.13 error means your postback request is exceeding IIS's default maximum content length limit. When you turn off pagination, the GridView renders all uploaded rows, which makes the page's postback payload way larger than IIS allows by default.

Fixes:

  • Adjust IIS request limits in Web.config: Add or update these settings to allow larger request sizes (adjust the values based on your needs—example below sets a 100MB limit):
    <system.web>
      <!-- maxRequestLength is in KB; 102400 KB = 100 MB -->
      <httpRuntime maxRequestLength="102400" executionTimeout="3600" />
    </system.web>
    <system.webServer>
      <security>
        <requestFiltering>
          <!-- maxAllowedContentLength is in bytes; 104857600 bytes = 100 MB -->
          <requestLimits maxAllowedContentLength="104857600" />
        </requestFiltering>
      </security>
    </system.webServer>
    
  • Stick with pagination: As a better long-term fix, keep pagination enabled and use the Session/temp table approach from the first issue. This avoids the huge postback payload and keeps your GridView performant.
3. 大文件入库时数据表响应缓慢

Storing large file binaries directly in a database table is almost always a performance killer—it bloats your table, slows down inserts, and makes queries sluggish.

Fixes:

  • Store files on disk/cloud, not in the database: Upload large files to a dedicated folder on your server (or a cloud storage service), then only save metadata (file path, name, size, upload date) in your database. This cuts down on insert time drastically and makes future access faster.
  • If you must store files in the database: Use optimized storage features like SQL Server's FILESTREAM—it stores large binary data on the filesystem but lets you access it through SQL queries, balancing performance and data management.
  • Use bulk insertion: Instead of inserting one record at a time, use SqlBulkCopy to batch insert all approved records. This reduces the number of round-trips to the database and speeds up the entire process.

内容的提问来源于stack exchange,提问作者Rick Kountz

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 08:27:40