Can't we use FileSystemRazorViewEngine from inside the controller? My requirement is to keep the mail template(Views) in a common path and use by mvc application as well as other console or windows application. In this I don't want to keep views inside the mvc app and refer by other application
[HttpPost]
public ActionResult SendSimple()
{
var viewsPath = Server.MapPath("~/Views/Emails");
var engines = new ViewEngineCollection();
engines.Add(new FileSystemRazorViewEngine(viewsPath));
var service = new EmailService(engines);
dynamic email = new Email("Simple");
email.Date = DateTime.UtcNow.ToString(); // This does not get translated into final output
service.Send(email);
return RedirectToAction("Sent", "Home");
}
Can't we use FileSystemRazorViewEngine from inside the controller? My requirement is to keep the mail template(Views) in a common path and use by mvc application as well as other console or windows application. In this I don't want to keep views inside the mvc app and refer by other application
[HttpPost] public ActionResult SendSimple() { var viewsPath = Server.MapPath("~/Views/Emails"); var engines = new ViewEngineCollection(); engines.Add(new FileSystemRazorViewEngine(viewsPath)); var service = new EmailService(engines);
dynamic email = new Email("Simple"); email.Date = DateTime.UtcNow.ToString(); // This does not get translated into final output service.Send(email); return RedirectToAction("Sent", "Home"); }
Same thing work from console application