jsreport - 在 C# 中访问被拒绝消息



我在执行此代码时收到Access Denied消息:

var report = await _service.RenderAsync(new RenderRequest
{
Template = new Template
{
Recipe = Recipe.PhantomPdf,
Engine = Engine.None,
Content = html,
Phantom = new Phantom()
{
Header = header,
Footer = footer,
HeaderHeight = GetElementHeightOrDefault(header),
FooterHeight = GetElementHeightOrDefault(footer)
}
}
});

实际上,它在执行_service.RenderAsync方法时失败,该方法是从IRenderService实现的服务。

这是错误消息:

at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at jsreport.Local.Internal.BinaryProcess.<InnerExecute>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at jsreport.Local.Internal.BinaryProcess.<ExecuteExe>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at jsreport.Local.Internal.LocalUtilityReportingService.<RenderAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()

我从jsreport中找到了这个线程,其中有人和我有同样的问题:formu.jsreport.net/topic/428

所以我按照这个步骤操作:

  1. 由于我在 IIS 中有一个 Web 应用程序和一个 IIS API 服务,因此我将 IUSR 和 IIS_IUSRS 添加到应用程序中,并授予它们最高权限
  2. 确保我的解决方案是在管理员权限下执行
  3. 禁用了所有防病毒软件和 Windows 安全中心

这些都没有奏效。我仍然在这里幻想同样的问题。

有人可以帮助我吗?

可能与模拟有关,因此,如果代码未在特定模拟上下文下执行,并且所有代码都通过 IIS 模拟运行,因此我们可能需要创建一些与 AppPool 相关的跟踪:

  1. 尝试将应用程序池中的模拟更改为管理员用户:

IIS>应用程序池>高级设置>标识(并进行更改( 到管理员帐户(。

  1. 给包含渲染内容的目录一个everyone许可。

此外,根据您的评论,本地系统具有最高权限,而网络服务或 ApplicationPoolIdentity 具有执行应用程序的最小权限,因此这就是本地系统可以解决大多数模拟问题的原因。

最新更新