ASP.NET Core 6 "Cannot implicitly convert type 'Rotativa.ViewAsPdf' to 'Microsoft.AspNetCore.Mvc.ActionResult'"

Viewed 85

I want to make PDF export in my ASP.NET Core 6 project. I use 'Rotativa' and this code to export:

public Microsoft.AspNetCore.Mvc.ActionResult Export()
{
    return new ViewAsPdf("PdfReport");
}

I get this error:

Cannot implicitly convert type 'Rotativa.ViewAsPdf' to 'Microsoft.AspNetCore.Mvc.ActionResult'. An explicit conversion exists (are you missing a cast?)

Please help me - what do I need to do?

Thanks.

2 Answers

Use IActionResult instead ActionResult

public IActionResult Export()
{
    return new ViewAsPdf("PdfReport");
}

I just install 'Rotativa.AspNetCore' package and everything is ok.

Related