几个月前,我向Azure网站部署了一个应用程序,并且它按预期工作。昨天,在微软发布了一系列新功能之后,我注意到有一个选项可以从32位变成64位。我将网站配置从32位更改为64位。除了当我尝试使用标准SMTP .NET库通过SendGrid发送电子邮件时,所有网站都能正常工作。SMTP在64位模式下无法在Azure网站上工作
这是个例外,我得到:
访问被拒绝 “来源= ”系统“ 详细=” System.Net.NetworkInformation.NetworkInformationException(0X80004005):访问是在System.Net.NetworkInformation否认System.Net.Net.Net.Net.Information.SystemIPGlobalProperties.GetFixedInfo()在System.Net.Net.Net.Net.NetworkInformation.SystemIPGlobalProperties.get_FixedInfo()System.Net.Mail.SmtpClient.Initialize()System.Net.Mail.SmtpClient ..()
这是代码:
var toAddress = new MailAddress(to, username);
using (var smtp = new SmtpClient())
using (var message = new MailMessage() {Subject = subject, IsBodyHtml = true})
{
message.To.Add(toAddress);
message.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(body, null, MediaTypeNames.Text.Html));
smtp.Send(message);
}
Web.config文件:
<system.net>
<mailSettings>
<smtp from="[email protected]">
<network host="smtp.sendgrid.net" port="587" userName="[email protected]" password="xxxxx" />
</smtp>
</mailSettings>
</system.net>
我的开发环境配置为64位和应用程序能够发送电子邮件。 任何想法为什么它在Azure 64位模式下失败?
谢谢!
您是否将Cloud Service部署在'Full Trust'或'Windows Azure Partial Trust'中? – astaykov
我正在使用网站进行部署。这是默认的完全信任。 – tmorell
我有同样的问题。切换回32位固定它。有没有人有解释的差异? – CodeGrue