我有一个使用 Crystal 报表的 MVC 应用程序。我使用以下代码下载报告,
ReportDocument rd = new ReportDocument();
rd.Load(Path.Combine(Server.MapPath("~/Reports/" + Session["rpt"])));
rd.SetDataSource(Session["result"]);
Response.Buffer = false;
Response.ClearContent();
Response.ClearHeaders();
//Excel
Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
stream.Seek(0, SeekOrigin.Begin);
return File(stream, "application/vnd.ms-excel", "Cheque.xls");
最佳答案
Godaddy 的共享主机不支持 Crystal 报表。 不仅是Godaddy的共享主机,大部分主机商的共享主机也不支持 Crystal 报表。要使用 Crystal 报表,您必须购买 VPS 或专用服务器。
如果要在服务器上运行 Crystal 报表,则始终需要该服务器上的 Crystal 报表运行时。 GoDaddy 的共享主机服务器使用默认的中等信任级别,不支持 Crystal 报表运行时的安装。
有用信息:
GoDaddy's shared hosting servers use the default Medium trust level with the addition of OleDbPermission, OdbcPermission, and a less-restrictive WebPermission.
Applications operating under a Medium trust level have no registry access, no access to the Windows event log, and cannot use reflection. Such applications can communicate only with a defined range of network addresses and file system access is limited to the application's virtual directory hierarchy. Please make sure that your application can work in a Medium trust environment if you are having any problems with it.
因此人们可以将其用作共享托管权限的一般指示。
支持 Crystal Report 的共享主机之一是 http://asphostportal.com .我不确定这一点。 我从其他社区获得了这些信息。
关于c# - 带有 Crystal Report 的 .Net 应用程序无法在共享主机中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47545523/