我的应用程序在本地调试中工作正常,但在Azure免费网站上没有用于一个特定的复杂操作结果。我的GlobalFilterException甚至无法捕获这个错误(即使它适用于所有其他错误,即使在Release中)...也许是因为它是服务器的问题,而不是我的应用程序?
因为我的Globalfilter没有抓到这个bug,所以我有这个浏览器错误页面:
HTTP 500内部服务器错误
我尝试在Azure上激活日志,这是最后一项:
FTP目录/ LogFiles / http / RawLogs / 2014-12-10 02:03:08 myproject GET / email / sendemail - 0 - - - - - myproject 500 121 0 294 3525 229998
我在那里看到“500”......也许这又是一个关于内部服务器错误的线索?
崩溃的地方:
似乎在ActionResult中间崩溃,因为在我发送电子邮件之后,我使用已发送电子邮件的所有ID更新我的数据库。但是,在Azure上发布时,数据库中没有更新任何内容,但会发送一些电子邮件。
这是我非常确定存在错误的部分:
try
{
Parallel.ForEach(writeEmailViewModel.SelectedContactGroupIDs, new ParallelOptions { MaxDegreeOfParallelism = maxParallelEmail }, selectedID =>
{
var destination = new Destination() { ToAddresses = (new List<string>() { companyContactGroups.First(s => s.ContactGroupID == selectedID).Contact.Email }) };
var client = new AmazonSimpleEmailServiceClient("***", "***", RegionEndpoint.USEast1);
var from = "=?utf-8?B?" + System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(UserData.CompanyName)) + "?= <***>";
var request = new SendEmailRequest(from, destination, message) { ReplyToAddresses = new List<string>() { writeEmailViewModel.ReplyToEmail } };
var response = client.SendEmail(request);
responseInfoList.Add(new KeyValuePair<string, string>(selectedID, response.MessageId));
});
}
finally
{
// Replace this with delivery notification
foreach (var responseInfo in responseInfoList)
{
var emailCampaignContact = emailCampaignContactList.First(s => s.ContactID == companyContactGroups.First(r => r.ContactGroupID == responseInfo.Key).ContactID);
emailCampaignContact.IsSent = true;
emailCampaignContact.MessageID = responseInfo.Value;
db.Entry(emailCampaignContact).State = EntityState.Modified;
}
db.SaveChanges();
}
有什么想法吗?