Please help me I've got this problem recently: I was trying to generate pdf from view but I've got some issues on server side after publishing
Exception: Access is denied Controller: Example Action: ExampleView
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at Rotativa.WkhtmltopdfDriver.Convert(String wkhtmltopdfPath, String switches, String html)
at Rotativa.AsPdfResultBase.CallTheDriver(ControllerContext context)
at Rotativa.AsPdfResultBase.BuildPdf(ControllerContext context)
at Rotativa.AsPdfResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19()
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<>c__DisplayClass2a.<BeginInvokeAction>b__20()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult)
I have really no idea what is going on... Rotativa version 1.6.1 locally its working but on server I get this error... Controller:
namespace ZarzadzaniePortalem.Controllers
{
[Authorize]
public class ExampleController : Controller
{
public ActionResult ExampleView()
{
return new Rotativa.ActionAsPdf("ExampleToPrint")
{
FileName = "ExampleToPrint.pdf"
};
}
[AllowAnonymous]
public ActionResult ExampleToPrint()
{
/* some viewbags */
return View();
}
}
}
hope your issue was resolved. If not, then let me post one of the solutions that worked.
ActionAsPdf()
you can use theViewAsPdf()
.