简体   繁体   English

ASP.NET Core 6“无法将类型'Rotativa.ViewAsPdf'隐式转换为'Microsoft.AspNetCore.Mvc.ActionResult'”

[英]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.我想在我的 ASP.NET Core 6 项目中导出 PDF 。 I use 'Rotativa' and this code to export:我使用“Rotativa”和这段代码来导出:

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'.无法将类型“Rotativa.ViewAsPdf”隐式转换为“Microsoft.AspNetCore.Mvc.ActionResult”。 An explicit conversion exists (are you missing a cast?)存在显式转换(您是否缺少演员表?)

Please help me - what do I need to do?请帮助我 - 我需要做什么?

Thanks.谢谢。

Use IActionResult instead ActionResult使用IActionResult代替ActionResult

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

I just install 'Rotativa.AspNetCore' package and everything is ok.我只安装了“Rotativa.AspNetCore”package,一切正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法将类型“bool”隐式转换为“Microsoft.AspNetCore.Mvc.ActionResult” - Cannot implicitly convert type 'bool' to 'Microsoft.AspNetCore.Mvc.ActionResult' 错误 CS0029 无法将类型“Microsoft.AspNetCore.Mvc.ActionResult”隐式转换为“System.Collections.Generic.List&lt;&gt;” - Error CS0029 Cannot implicitly convert type 'Microsoft.AspNetCore.Mvc.ActionResult' to 'System.Collections.Generic.List<>' 无法将类型“System.Web.Mvc.ViewResult”隐式转换为“Microsoft.AspNetCore.Mvc.IActionResult”-Asp.Net MVC 5 - Cannot implicitly convert type 'System.Web.Mvc.ViewResult' to 'Microsoft.AspNetCore.Mvc.IActionResult' - Asp.Net MVC 5 无法从“Microsoft.AspNetCore.Mvc.ActionResult”转换为“System.Collections.Generic.IEnumerable”<string> &#39; - Cannot convert from 'Microsoft.AspNetCore.Mvc.ActionResult' to 'System.Collections.Generic.IEnumerable<string>' 无法将类型“Microsoft.AspNetCore.Mvc.NotFoundObjectResult”隐式转换为 MyDto - Cannot implicitly convert type 'Microsoft.AspNetCore.Mvc.NotFoundObjectResult' to MyDto 将 Rotativa.ViewAsPdf 转换为 System.Mail.Attachment - convert Rotativa.ViewAsPdf to System.Mail.Attachment 无法隐式转换类型“Microsoft.AspNetCore.Mvc.BadRequestObjectResult” - Cannot implicitly convert type 'Microsoft.AspNetCore.Mvc.BadRequestObjectResult' CS0029 C# 无法将类型隐式转换为“int?” ASP.NET CORE 5 MVC 标识 - CS0029 C# Cannot implicitly convert type to 'int?' ASP.NET CORE 5 MVC Identity 无法将类型字符串隐式转换为int asp.net mvc - Cannot implicitly convert type string to int asp.net mvc ASP.NET 核心 3:InvalidOperationException:没有 Microsoft.AspNetCore.Mvc.Routing.ControllerActionEndpointDataSource 类型的服务已注册 - ASP.NET Core 3: InvalidOperationException: No service for type Microsoft.AspNetCore.Mvc.Routing.ControllerActionEndpointDataSource has been registered
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM