我在使用FileUpload處理大文件時遇到問題。如果我上傳一個小文件(〜10kB),它可以正常工作。上傳一個大文件(〜60MB)不會引發異常,它只是重新加載頁面。之前有人問:<httpRuntime maxRequestLength="2097151" executionTimeout="3600" waitChangeNotification="1" maxWaitChangeNotification="3600" requestValidationMode="2.0" />
ASP FileUpload安靜失敗
頁:
<%@ 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>
後面的代碼:
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;
}
}
編輯:我已經嘗試接受的答案下面,我這樣想着。再次看我發現有兩個<system.webServer>
部分在我的web.config中都需要更改。