ASP文件上传无声故障 [英] ASP FileUpload Silent Fail

查看:113
本文介绍了ASP文件上传无声故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用使用文件上传大文件的问题。如果我上传一个小文件(10KB〜),它工作正常。上传大文件(60MB〜)不会抛出异常,它只是重新加载页面。之前有人问:<的httpRuntime的maxRequestLength =2097151executionTimeout =3600waitChangeNotification =1maxWaitChangeNotification =3600requestValidationMode =2.0/>

I'm having a problem using using FileUpload for large files. If I upload a small file (~10kB), it works fine. Uploading a large file (~60MB) does not throw an exception, it just reloads the page. Before anyone asks: <httpRuntime maxRequestLength="2097151" executionTimeout="3600" waitChangeNotification="1" maxWaitChangeNotification="3600" requestValidationMode="2.0" />

页:

<%@ AutoEventWireup="true" CodeFile="~/LargeFileUploadControl.aspx.cs" Inherits="LargeFileUploadControl" %>
<html>
<body>

<form runat="server">
<asp:Label ID="theOnlyLabel" runat="server" Text="Uploaded files will go to a place"/><br />
<asp:FileUpload ID="theOnlyUpload" runat="server" /><br />
<asp:Button ID="theOnlyButton" onClick="StartUpload" Text="Upload" runat="server" />
</form>
</body>
</html>

背后code:

public partial class LargeFileUploadControl:Page
{
public string _uploadDir;

/// <summary>
/// Content loaded event handler
/// </summary>
protected override void  OnLoad(EventArgs e)
{
    base.OnLoad(e);
    _uploadDir = "D:\\web\\tikt.imaginuity.com\\TIKT\\media\\TIKT\\Global Large Uploads\\";
    theOnlyLabel.Text = "Uploaded files will go to " + _uploadDir;
}


protected void StartUpload(object sender, EventArgs e)
{
    if (theOnlyUpload.HasFile)
    {
        theOnlyLabel.Text = "Uploading...";
        theOnlyUpload.SaveAs(_uploadDir + theOnlyUpload.FileName);
        theOnlyLabel.Text = "File saved to " + _uploadDir + theOnlyUpload.FileName;
    }
    else
    {
        theOnlyLabel.Text = "No file to upload";
    }

    return;
}
}

编辑:我已经尝试下面的接受的答案,我这样想着。展望我再次发现,有的两个&LT; system.webServer方式&gt; 在我的web.config这两个需要改变的部分。

EDIT : I had already tried the accepted answer below, or so I thought. Looking again I discovered that there were two <system.webServer> sections in my web.config that both needed the change.

推荐答案

这将解决您的问题,如果您使用的是IIS7。我在上传文件的大​​小超过400MB,

This will fix your issue, if you are using iis7. I tested on upload file size more than 400MB,

在添加元素下web.config文件中进行配置。

Add the following configuration in your web.config file under element.

<security>
  <requestFiltering>
    <requestLimits maxAllowedContentLength="524288000"/>
  </requestFiltering>
</security>

这篇关于ASP文件上传无声故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆