How to render html string from razor view with model
This is sample example
using RazorEngine;
//this is for c# controller
string text = System.IO.File.ReadAllText(System.IO.Path.Combine(Server.MapPath("~/Mvc/Views/SinCairForm/EmailTemplate.cshtml")));
emailBody = Razor.Parse(text, new { Message = "hello", Serial="2017-009", WebURL= "http://localhost:49557" });
//this is for view
<div>@Model.Message</div>
<div>@Model.Serial</div>
using RazorEngine;
//this is for c# controller
string text = System.IO.File.ReadAllText(System.IO.Path.Combine(Server.MapPath("~/Mvc/Views/SinCairForm/EmailTemplate.cshtml")));
emailBody = Razor.Parse(text, new { Message = "hello", Serial="2017-009", WebURL= "http://localhost:49557" });
//this is for view
<div>@Model.Message</div>
<div>@Model.Serial</div>
Comments
Post a Comment