Posts

Showing posts from November, 2017

How to get base domain url in asp.net mvc

How to get base domain url in asp.net mvc string webUrl = new Uri(Request.Url, Url.Content("~")).AbsoluteUri.TrimEnd('/');

How to send mail with attached file without store in local server

 How to send mail with attached file without store in local server 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=DateTime.Now.Year.ToString(), WebURL= "http://localhost:49557" });                                               MailMessage mail = new MailMessage("dev@convertium.com", "kesikan@convertium.com", "Subject", emailBody);                         mail.IsBodyHtml = true;                         System.IO.MemoryStream stream = new System.IO.MemoryStream();               ...

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>