if (fileup.HasFile)
{
try
{
string path = Server.MapPath("./"); //当前路径
path += fileup.FileName;
if (File.Exists(path))
{
lblUp.Text = "<font size='2' color='#8F8F8F'>服务器上已经有了你正在上传的文件 " + fileup.PostedFile.FileName+"</font>";
}
else
{
fileup.SaveAs(path);
this.ClientScript.RegisterStartupScript(this.GetType(), "", "showSucc('文件上传成功!')", true);
lblUp.Text = "<font size='2' color='#8F8F8F'>File Name: " +
fileup.PostedFile.FileName + "<br>" +
fileup.PostedFile.ContentLength + "kb<br>" +
"Content Type: " +
fileup.PostedFile.ContentType + "</font>";
}
}
catch (Exception ex)
{
lblUp.Text = "ERROR: " + ex.Message.ToString();
}
}
else
{
lblUp.Text = "<font size='2' color='#8F8F8F'>您尚未选择你要上传的文件,或您要上传的文件已经不存在</font>";
}这是文件的上传的代码,可是只要上传的文件超过4M页面就显示无法显示该页面,我上网查了很多解决方案,比如在什么WebConfig中配置maxRequestLength的值,可是这是行不通的。另外更改IIS中的一些设置,可是我认为这个方案也不合理,因为不可能要求每个客户都去更改IIS的。想请各位高手帮帮忙啊,需要代码解决啊。
<system.web>
<httpRuntime executionTimeout="600" maxRequestLength="204800" />
</system.web>
<location path="FileUpDownPrj/web/Default.aspx">
<system.web>
<httpRuntime executionTimeout="90" maxRequestLength="10240" useFullyQualifiedRedirectUrl="false"
minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100"/>
</system.web>
</location>
为什么这样就不行呢