看来当我使用邮政发送电子邮件使用布局时,标题没有被解析并包含在邮件中.
查看/电子邮件/ _ViewStart.cshtml
@{ Layout = "~/Views/Emails/_EmailLayout.cshtml"; }
查看/电子邮件/ _EmailLayout.cshtml
<html> <head> <Meta name="viewport" content="width=device-width" /> <title>ViewEmails</title> </head> <body> <div> @RenderBody() </div> </body> </html>
查看/电子邮件/ ResetPassword.cshtml
To: @ViewBag.To From: @ViewBag.From Subject: Reset Password Views: Html
查看/电子邮件/ ResetPassword.html.cshtml
Content-Type: text/html; charset=utf-8 Here is your link,etc ...
当我收到邮件时,所有标题To,From,Subject和Views都包含在正文中.
任何人都知道如何正确执行
UPDATED(感谢Andrew),这样做:
查看/电子邮件/ _EmailLayout.cshtml
@RenderSection("Headers",false) <!DOCTYPE html> <html> <head> <Meta name="viewport" content="width=device-width" /> <title>ViewEmails</title> </head> <body> <div> @RenderBody() </div> </body> </html>
查看/电子邮件/ ResetPassword.cshtml
@section Headers { To: @ViewBag.To From: @ViewBag.From Subject: Reset Password Views: Html }
查看/电子邮件/ ResetPassword.html.cshtml
@section Headers { Content-Type: text/html; charset=utf-8 } Here is your link,etc ...