postal icon indicating copy to clipboard operation
postal copied to clipboard

Using FileSystemRazorViewEngine inside controller - Views data are not translated

Open premchandrasingh opened this issue 9 years ago • 0 comments

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

premchandrasingh avatar Jan 27 '15 17:01 premchandrasingh