protected void Button1_Click(object sender, EventArgs e)
{
if (FileUploadControl.HasFile)
{
try
{
string filename = Path.GetFileName(FileUploadControl.FileName);
FileUploadControl.SaveAs(Server.MapPath("~/Files/") + filename);
StatusLabel.Text = "Upload status: File uploaded!";
String x = Server.MapPath("~/Files/") + filename;
}
catch (Exception ex)
{
StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
}
}
}
在这个简单的例子中,当我尝试低于1MB的文件时,它运行良好,但如果我尝试10MB,我会得到“无法访问此站点连接已重置。”这是浏览器消息。
那么问题出在哪里?
答案 0 :(得分:2)
检查你的web.config文件(10mb和5分钟):
<system.web>
<httpRuntime maxRequestLength="102400" executionTimeout="300"/>
</system.web>