gpt4 book ai didi

c# - 在服务器上启用模拟时 Rotativa 不工作

转载 作者:太空宇宙 更新时间:2023-11-03 14:45:52 25 4
gpt4 key购买 nike

我正在使用 Rotativa 从 View 生成 PDF。它在我的本地主机上工作,但是当我推送到我的服务器时它根本不起作用。服务器启用了 Windows 身份验证和模拟,我需要为该站点启用。

这是我尝试在服务器上运行代码时遇到的错误

Qt: Could not initialize OLE (error 80070005) Error: Failed loading page https://api.mydomain.com/Reports/RedBluePDF?community=CommunityName&procedure=GetTasks (sometimes it will work just to ignore this error with --load-error-handling ignore) Exit with code 1 due to http error: 1003

这是我的代码:

public byte[] getReportsPDF(string community, string procedure)
{

byte[] pdfBytes = new byte[] { };

RouteData route = new RouteData();
route.Values.Add("controller", "SiteSuperReports");
route.Values.Add("action", "RedBluePDF");

this.ControllerContext = new ControllerContext(new HttpContextWrapper(System.Web.HttpContext.Current), route, this);

if (procedure == "GetProductionTasks")
{

var actionPDF = new Rotativa.ActionAsPdf("RedBluePDF", new { community = community, procedure = procedure })
{
PageSize = Size.A4,
PageOrientation = Rotativa.Options.Orientation.Landscape,
PageMargins = { Left = 1, Right = 1 }
};

try
{
pdfBytes = actionPDF.BuildFile(ControllerContext);
}
catch(Exception e)
{
Console.Write(e.Message.ToString());
}
}

return pdfBytes;
}

这里是 RedBluePDF 方法,它只返回一个 View :

public ActionResult RedBluePDF(string community, string procedure) {
return View();
}

我做错了什么,为什么这在我的服务器上不起作用,但在我的本地主机上却起作用?以及如何让它在我的服务器上运行。

最佳答案

尝试以下解决方案之一:

1- 转到 IIS > 站点 > 身份验证,单击“ASP.NET 模拟”并将其禁用。

2- 如果您要调用脚本或文件或其他任何内容,请指定使用的协议(protocol):

src="//api.mydomain.com/?????

到:

src="http://api.mydomain.com/?????

3- 在您的应用程序池配置中,在进程模型下,有一个选项“加载用户配置文件”。默认为 False,设置为 true。

关于c# - 在服务器上启用模拟时 Rotativa 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54243143/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com