hosein dafeyan
hosein dafeyan

Reputation: 117

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

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.

Upvotes: 1

Views: 1301

Answers (2)

hosein dafeyan
hosein dafeyan

Reputation: 117

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

Upvotes: 1

Okan Karadag
Okan Karadag

Reputation: 3045

Use IActionResult instead ActionResult

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

Upvotes: 1

Related Questions