У меня есть приложение MVC5, которое использует RazorEngine для создания электронных писем. Каждое электронное письмо находится в шаблоне cshtml. В шаблоны передаются данные, поэтому их кэширование не очень помогает, хотя я это делаю. Есть ли что-нибудь еще, что я могу сделать, чтобы уменьшить время, необходимое для рендеринга? Для рендеринга на сервере Azure требуется несколько секунд.
@{
ViewBag.Title = "_EmailResetPassword";
}
@{ var PasswordToken = Model.token; }
@{ var URLpath = Model.URLpath; }
@{ string link = string.Format("http://{0}/Account/ResetPassword/?tokenid={1}", URLpath, PasswordToken); }
<html>
<head>
<title></title>
<style type="text/css">
.auto-style1 {
text-align: center;
}
.auto-style2 {
background: white;
text-align: left;
font-size: 11.0pt;
font-family: Helvetica, sans-serif;
color: #4D4D4D;
}
</style>
</head>
<body>
<div class="auto-style1">
<h3 class="auto-style2">Dear @Model.FirstName,</h3>
<h3 class="auto-style2">We have reset your password at Eph Apparel for the username: @Model.UserName</h3>
<h3 class="auto-style2">Please click on the following link to create a new password:</h3>
<h3 style='text-align:center;background:white'><span lang=EN-CA
style='font-size:11.0pt;font-family:"Helvetica","sans-serif"'>
<a href="@link">Reset Password</a></span></h3>
<h3 style='text-align:center;background:white'><span lang=EN-CA
style='font-size:11.0pt;font-family:"Segoe UI","sans-serif";color:#4D4D4D'>LIKE US ON </span>
<span> <a href="https://www.facebook.com/ephapparel" target="_blank"><img alt="" width=25 height=22
src="http://ephoms-prod.azurewebsites.net/images/eph_graphics/fb_icon.png" ></a></span>
<span lang=EN-CA style='font-size:11.0pt;font-family:"Segoe UI","sans-serif";
color:#4D4D4D'> FOLLOW US ON </span><span lang=EN-CA></span>
<span><a href="https://www.twitter.com/ephApparel" target="_blank"><img alt="" width=25 height=23
src="http://ephoms-prod.azurewebsites.net/images/eph_graphics/twitter_icon.png"></a></span></h3>
<br>
<img alt="" src="http://ephoms-prod.azurewebsites.net/images/eph_graphics/eph_logo.png">
</div>
</body>
</html>
Код позади:
private string ResetPassword(Customer oCustomer, string oToken)
{
string oURLpath = GetConfigSettingById(3);
string template = System.IO.File.ReadAllText(HostingEnvironment.MapPath("/bin/EmailTemplates/_EmailResetPassword.cshtml"));
string message = Razor.Parse(template, new { FirstName = oCustomer.FirstName, UserName = oCustomer.Email, token = oToken, URLpath = oURLpath }, "Reset");
return message;
}