我這裏有一個代碼,這實際上轉換HTML到PDF,並將其發送到電子郵件,但它是在的ActionResult:C#更改的ActionResult到IHttpActionResult使用POST方法
public ActionResult Index()
{
ViewBag.Title = "Home Page";
var coverHtml = RenderRazorViewToString("~/Views/Home/Test.cshtml", null);
var htmlContent = RenderRazorViewToString("~/Views/Home/Test2.cshtml", null);
string path = HttpContext.Server.MapPath("~/Content/PDF/html-string.pdf");
PDFGenerator.CreatePdf(coverHtml, htmlContent, path);
//PDFGenerator.CreatePdfFromURL("https://www.google.com", path);
EmailHelper.SendMail("[email protected]", "Test", "HAHA", path);
return View();
}
我想變成一個API格式(api/SendPDF)使用POST與它將被髮送到的內容ID和電子郵件地址,但我不知道該怎麼做,因爲我對MVC和Web API非常陌生。在這方面感謝一些幫助。