我这里有一个代码,这实际上转换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非常陌生。在这方面感谢一些帮助。