我尝试使用“ HtmlToPdf” nuget将HTML转换为PDF,在本地测试中工作正常,但是当我将网站上传到主机时出现此错误:
Conversion error: Authentication error.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: Conversion error: Authentication error.
这是我的Convert方法代码
[AllowAnonymous]
public actionResult Convert(int id)
{
HtmlToPdf converter = new HtmlToPdf();
var context = system.web.HttpContext.Current;
string baseUrl = context.Request.Url.Host + ":"+context.Request.Url.Port + "/Doctor/DietTherapy/LineRegimePrint/";
PdfDocument doc = converter.ConvertUrl(baseUrl + id);
// save pdf document
byte[] pdf = doc.Save();
// close pdf document
doc.Close();
// return resulted pdf document
FileResult fileResult = new FileContentResult(pdf,"application/pdf");
fileResult.FileDownloadName = "Document.pdf";
return fileResult;
}
我如何授权用户进行此转换?