Telerik 使用 net6 报告 Html5 时发生错误

问题描述 投票:0回答:1

我正在尝试在我的项目中手动添加 telerik 报告工具。但低于错误。

{
    "message": "An error has occurred.",
    "exceptionMessage": "Method not found: 'Void Microsoft.AspNetCore.Mvc.JsonResult..ctor(System.Object, Newtonsoft.Json.JsonSerializerSettings)'.",
    "exceptionType": "MissingMethodException",
    "stackTrace": null
}

程序.cs

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers().AddNewtonsoftJson();
builder.Services.AddControllersWithViews();


builder.Services.TryAddScoped<IReportSourceResolver, CustomReportSourceResolver>();
builder.Services.TryAddSingleton<IReportServiceConfiguration>(sp =>
new ReportServiceConfiguration
{
ReportingEngineConfiguration = sp.GetService<IConfiguration>(),
HostAppId = "ReportingNet6",
Storage = new FileStorage(),
ReportSourceResolver = new TypeReportSourceResolver()
.AddFallbackResolver(new UriReportSourceResolver(
    System.IO.Path.Combine(sp.GetService<IWebHostEnvironment>().ContentRootPath, "Reports"))
    .AddFallbackResolver(new CustomReportSourceResolver()))

});
var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Home/Error");
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();
app.UseEndpoints(endpoints =>
{
    endpoints.MapControllers();
});

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");

app.Run();

报告控制器

 [Route("api/reports")]
    public class ReportsController : ReportsControllerBase
    {
        public ReportsController(IReportServiceConfiguration reportServiceConfiguration)
               : base(reportServiceConfiguration)
        {
        }
    }

景色

@{
    ViewData["Title"] = "Home Page";
}
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>

<link href="https://kendo.cdn.telerik.com/2019.1.115/styles/kendo.common.min.css" rel="stylesheet" id="common-css" />
<link href="https://kendo.cdn.telerik.com/2019.1.115/styles/kendo.blueopal.min.css" rel="stylesheet" id="skin-css" />

<div id="reportViewer1">
    loading...
</div>

@section Scripts
{
    
    <script src="api/reports/resources/js/telerikReportViewer"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            $("#reportViewer1").telerik_ReportViewer({
                serviceUrl: "/api/reports/",
                reportSource: {
                    report: "Product Sales.trdp",
                    parameters: {
                        CultureID: "en"
                    }
                }
            });
        });
    </script>
}
c# .net-6.0 telerik-reporting
1个回答
0
投票

@sina_Islam 你能解决这个问题吗?

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.