ฉันกำลังพยายามใช้การยืนยันอีเมลกับ SendGrid ข้อผิดพลาดที่ฉันได้รับขณะพยายามลงทะเบียนโดยใช้ http://goo.gl/77WXpT บทช่วยสอนนี้คือ:
คำขอไม่ถูกต้อง
คำอธิบาย: มีข้อยกเว้นที่ไม่สามารถจัดการได้เกิดขึ้นระหว่างการดำเนินการคำขอเว็บปัจจุบัน โปรดตรวจสอบการติดตามสแต็กเพื่อดูข้อมูลเพิ่มเติมเกี่ยวกับข้อผิดพลาดและที่มาของโค้ด
รายละเอียดข้อยกเว้น: System.Exception: คำขอไม่ถูกต้อง
ข้อผิดพลาดแหล่งที่มา:
if (transportWeb != null)
{
await transportWeb.DeliverAsync(myMessage);
}
else
และซอร์สโค้ดของ IdentityConfig.cs คือ:
public class EmailService : IIdentityMessageService
{
public async Task SendAsync(IdentityMessage message)
{
await configSendGridasync(message);
}
// Use NuGet to install SendGrid (Basic C# client lib)
private async Task configSendGridasync(IdentityMessage message)
{
var myMessage = new SendGridMessage();
myMessage.AddTo(message.Destination);
myMessage.From = new System.Net.Mail.MailAddress(
"[email protected]", "Joe S.");
myMessage.Subject = message.Subject;
myMessage.Text = message.Body;
myMessage.Html = message.Body;
var credentials = new NetworkCredential(
ConfigurationManager.AppSettings["mailAccount"],
ConfigurationManager.AppSettings["mailPassword"]
);
// Create a Web transport for sending email.
var transportWeb = new Web(credentials);
// Send the email.
if (transportWeb != null)
{
await transportWeb.DeliverAsync(myMessage);
}
else
{
Trace.TraceError("Failed to create Web transport.");
await Task.FromResult(0);
}
}
}