我必须发送邮件附件。我的代码只适用于文件小于4MB。 我已经检查了网上的所有内容,但是所有人都建议使用相同的soolution。即在webconfig中更改我已经完成的httpruntime属性。无法上传文件大于4 MB使用文件上传在asp.net 3.5
<httpRuntime maxRequestLength="10000" executionTimeout="1500" />
我已经改变了在网络“超时”属性config.Also保持活动的应用程序配置做了更改IIS,但即使这样做后,这一切都改变了问题依然留在我application.everytime我尝试一切在1.5分钟后上传大于4mb的连接超时文件。
在点击事件
protected void btnSend_Click(object sender, EventArgs e)
{
MailMessage msg = new MailMessage();
SmtpClient smtp = new SmtpClient();
string strFrom = txtFrom.Text;
string strTo = txtTo.Text;
string strSubject= ddlTemplate.SelectedItem.Text.ToString();
string strBody =txtBody.Text;
string strCC =txtCC.Text;
string strBCC =txtBCC.Text;
if (this.fuAttachments.HasFile)
{
Attachment at = new Attachment(fuAttachments.PostedFile.InputStream,fuAttachments.PostedFile.ContentType);
at.ContentDisposition.FileName = this.fuAttachments.FileName;
msg.Attachments.Add(at);
}
smtp.EnableSsl = true;
msg.From = new MailAddress(strFrom);
msg.To.Add(strTo);
msg.Subject = strSubject;
msg.Body = strBody;
//smtp = new SmtpClient("localhost");
//smtp.UseDefaultCredentials = true;
try
{
smtp.Send(msg);
}
catch (SmtpException Ex)
{
throw;
}
if (msg.Attachments.Count > 0)
{
//Clear the attachments and delete the sessionid folder from tempFiles
msg.Attachments.Dispose();
}
}
您是否增加了执行超时? as 1500ms is 1.5sec – 2012-04-24 10:15:14
that's 1500 seconds not ms .... see [this](http://msdn.microsoft.com/en-us/library/e1f13641.aspx) – vatsal 2012-04-24 10:27:03
噢谢谢我纠正 – 2012-04-24 10:36:11