我正在开发一个新的 ASP.Net MVC 4 应用程序并测试用户登录。我收到以下异常:
System.Data.SqlClient.SqlException: Invalid column name 'Email'
我正在使用来自http://kevin-junghans.blogspot.com/2013/02/adding-email-confirmation-to.html的示例。
这是适当的代码:
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Register(RegisterModel model)
{
if (ModelState.IsValid)
{
// Attempt to register the user
try
{
string confirmationToken =
WebSecurity.CreateUserAndAccount(model.UserName, model.Password, new { Email = model.Email }, true);
System.Net.Mail.MailAddress from = new System.Net.Mail.MailAddress("noreply@cardmage.com");
System.Net.Mail.MailAddress[] to = new System.Net.Mail.MailAddress[1];
to[1] = new System.Net.Mail.MailAddress(model.Email);
System.Net.Mail.MailAddress[] cc = new System.Net.Mail.MailAddress[0];
System.Net.Mail.MailAddress[] bcc = new System.Net.Mail.MailAddress[0];
String Subject = "Please verify your e-mail address.";
String body = String.Format("Thank you for registering with CardMage." +
"To verify your account, please follow this link." +
"http://www.cardmage.co/Account/RegisterConfirmation/{0}", confirmationToken);
System.Net.NetworkCredential nc = new NetworkCredential("foo", "bar");
SendGrid sg = SendGrid.GetInstance(from, to, cc, bcc, Subject, body, "");
SMTP s = SMTP.GetInstance(nc);
s.Deliver(sg);
return RedirectToAction("RegisterStepTwo", "Account");
我究竟做错了什么?我试图从谷歌搜索中找到解决方案,但没有运气。我发现这个SO question 的属性值格式与我相同,所以我检查了我的数据库,但电子邮件列不存在。有人可以指出我正确的方向吗?感谢您的时间和考虑。