我在执行这段代码时遇到了 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
所以我按照以下步骤操作:
- 由于我在 IIS 中有一个 Web 应用程序和一个 IIS Api 服务,所以我将 IUSR 和 IIS_IUSRS 添加到应用程序中并赋予它们最高权限
- 确保我的解决方案在管理员权限下执行
- 禁用所有防病毒软件和 Windows 安全
但是这些都不起作用。我仍然在这里遇到同样的问题。
有人能帮帮我吗?
最佳答案
可能与模拟有关,因此如果代码未在特定模拟上下文下执行并且所有代码都通过 IIS 模拟运行,那么我们可能需要进行一些与 AppPool 相关的跟踪:
- 尝试将 AppPool 中的模拟更改为管理员用户:
IIS > Application Pools > Advanced Settings > Identity (and change it to the Admin account).
- 给包含渲染内容的目录一个
everyone
许可。
此外,根据您的评论,本地系统具有最高权限,而网络服务或 ApplicationPoolIdentity 具有执行应用程序的最低权限,因此本地系统可以解决大部分模拟问题。
关于c# - jsreport - C# 中的访问被拒绝消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57407245/