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

标签 c# asp.net .net iis jsreport

我在执行这段代码时遇到了 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. 尝试将 AppPool 中的模拟更改为管理员用户:

IIS > Application Pools > Advanced Settings > Identity (and change it to the Admin account).

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

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

关于c# - jsreport - C# 中的访问被拒绝消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57407245/

相关文章:

c# - 为什么在任务中运行的 Thread.Sleep 不会阻塞 WinForms UI 线程?

c# - 将数值的 IEnumerable 作为参数传递给方法

c# - 如何让我的变量从 dropdownlist asp.net 携带到总计并在 c# 中打印出来?

asp.net - 从网站发布中排除文件夹,而不是 Visual Studio 2012 中的 Web 应用程序项目

jquery - 如何使用 jQuery 设置 DropDownList 的选定值

c# - 检测 AppData\LocalLow 的位置

c# - 使用 LINQ 对列表条目进行分组

c# - Parallel.ForEach 迭代中的操作超时

c# - 从单独的列在 Entity Framework 中添加日期时间和时间

.net - 是否有任何IL编辑器来更改程序集的字节码?