我编写ASP.NET MVC应用程序
我有模特
public class MailModel
{
public string From { get; set; }
public string To { get; set; }
public string Subject { get; set; }
public string Body { get; set; }
public string Link { get; set; }
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:lol}", ApplyFormatInEditMode = true)]
public DateTime LinkStartTime { get; set; }
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:lol}", ApplyFormatInEditMode = true)]
public DateTime LinkEndTime { get; set; }
}
控制器
public ActionResult EmailInvitation()
{
return View();
}
[HttpPost]
public ViewResult EmailInvitation(SmartSolutions.Models.MailModel _objModelMail)
{
if (ModelState.IsValid)
{
var emailList = db.Clients.Select(u => u.Email).ToList();
var emails = String.Join(",",emailList);
MailMessage mail = new MailMessage();
mail.To.Add(emails);
mail.From = new MailAddress(_objModelMail.From = "suhomlin.eugene93@gmail.com");
mail.Subject = _objModelMail.Subject="Видео интервью";
string Body = _objModelMail.Body = "Предлагаем пройти интервью";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential
("**********", "***********");// Enter seders User name and password
smtp.EnableSsl = true;
smtp.Send(mail);
return View("EmailInvitation", _objModelMail as IEnumerable<MailModel>);
}
else
{
return View();
}
并查看
@model IEnumerable<SmartSolutions.Models.MailModel>
@{
Layout = "~/Views/Shared/_Layout5.cshtml";
}
@{
ViewBag.Title = "Индивидуальное приглашение";
}
<div class="inner-div3">
<div class="right-welcome-div2">
<table class="table">
<tr style="background: #d1d3d4">
<th></th>
<th style="font-size: 20px; text-align: center;">
@Html.DisplayNameFor(model => model.To)
</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td style="text-align: center; font-size: 18px;">
@Html.DisplayFor(modelItem => item.To)
</td>
</tr>
}
</table>
</div>
当我尝试启动视图时出现此错误
我不知道这个错误,也许有人可以帮助我吗?
我觉得模特一切都好。
非常感谢你的帮助。