I've developed some .trdp reports with the Report Designer R1 2018 standalone app and I'm trying to display them using an MVC view and Telerik Reporting v 12.0.18.125. I had it working for about an hour last week, but since then I keep running into a 400 Bad Request error with the message "Report name missing".
I added the View and required REST API and everything else by using the Add->New Item->Telerik MVC Report Viewer View R1 2018 template. The ReportsController is unchanged from the default that was added:
public
class
ReportsController : ReportsControllerBase
{
static
ReportServiceConfiguration configurationInstance;
static
ReportsController()
{
var appPath = HttpContext.Current.Server.MapPath(
"~/"
);
var reportsPath = Path.Combine(appPath,
"Reports"
);
var resolver =
new
ReportFileResolver(reportsPath)
.AddFallbackResolver(
new
ReportTypeResolver());
configurationInstance =
new
ReportServiceConfiguration
{
HostAppId =
"Html5App"
,
Storage =
new
FileStorage(),
ReportResolver = resolver,
};
}
public
ReportsController()
{
this
.ReportServiceConfiguration = configurationInstance;
}
}
Likewise, the View is the default that was added (renamed to TestReport.cshtml):
@using Telerik.Reporting
@using Telerik.ReportViewer.Mvc
@{
Layout = null;
}
<!DOCTYPE html>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
>
<
title
>Telerik MVC HTML5 Report Viewer</
title
>
<
meta
http-equiv
=
"X-UA-Compatible"
content
=
"IE=edge"
>
<
meta
name
=
"viewport"
content
=
"width=device-width, initial-scale=1, maximum-scale=1"
/>
<
script
src
=
"http://code.jquery.com/jquery-1.9.1.min.js"
></
script
>
<
link
href
=
"http://kendo.cdn.telerik.com/2015.3.930/styles/kendo.common.min.css"
rel
=
"stylesheet"
/>
<
link
href
=
"http://kendo.cdn.telerik.com/2015.3.930/styles/kendo.blueopal.min.css"
rel
=
"stylesheet"
/>
<!--kendo.all.min.js can be used as well instead of the following custom Kendo UI subset-->
<
script
src
=
"@Url.Content("
~/ReportViewer/js/telerikReportViewer.kendo-12.0.18.125.min.js")"></
script
>
<
style
>
#reportViewer1 {
position: relative;
width: 1300px;
height: 900px;
font-family: Verdana, Arial;
}
</
style
>
<
script
src
=
"@Url.Content("
~/ReportViewer/js/telerikReportViewer-12.0.18.125.min.js")"></
script
>
</
head
>
<
body
>
@(Html.TelerikReporting().ReportViewer()
.Id("reportViewer1")
.ServiceUrl(Url.Content("~/api/reports"))
.ReportSource(new UriReportSource() { Uri = "TestReport.trdp" })
.ViewMode(ViewMode.Interactive)
.ScaleMode(ScaleMode.Specific)
.Scale(1.0)
.PersistSession(false)
.PrintMode(PrintMode.AutoSelect)
.EnableAccessibility(false)
)
</
body
>
</
html
>
The following line was added to Global.asax.cs by the wizard:
Telerik.Reporting.Services.WebApi.ReportsControllerConfiguration.RegisterRoutes(System.Web.Http.GlobalConfiguration.Configuration);
There is a Reports folder containing the file TestReport.trdp, as well as a ReportViewer/js folder containing two telerikReportViewer*.js files. There is a TestReport action in my Test controller that simply returns View(). I am not aware of any changes I've made to the defaults made by the wizard (e.g. no custom report resolver).
When I hit that view and look at the Network traffic in developer tools, I can see that it successfully makes a request to http://localhost:12345/api/reports/clients and receives a response, so I believe the REST service is running. However, when it tries to call http://localhost:12345/api/reports/clients/115238-abc3/parameters with request body {parameterValues:{}, report:"TestReport.trdp"}, it always responds with {"message":"Missing report name"}, regardless of whether the filename in the Uri is one I know to be in the Reports folder.
I'm able to render and export the report as a PDF by putting the following in an Action, so I believe that a) the report can be found and read and b) it is not corrupt or otherwise has errors:
ReportProcessor rp =
new
ReportProcessor();
Hashtable deviceInfo =
new
Hashtable();
UriReportSource reportSource =
new
UriReportSource();
reportSource.Uri =
"Reports/TestReport.trdp"
;
RenderingResult result = rp.RenderReport(
"PDF"
, reportSource, deviceInfo);
using
(FileStream fs =
new
FileStream(outputPath, FileMode.Create)) {
fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length);
}
I also set up a very small MVC project to try to debug and successfully got reports to render in that. When I try to resolve a report that doesn't exist (e.g. zzzTestReport.trdp) using this project, it returns the message "Report 'zzzTestReport.trdp' cannot be resolved.", so I believe the "Missing report name" error has nothing to do with not being able to find the report.
I've tried importing the .trdp file to create a report class and rendering using a TypeReportSource, and I've even tried removing any trace of the report viewer from the project and re-adding it. No matter what I do, I keep getting the same "Missing report name" error. I'm guessing there's a configuration error or something hidden deep in my project, but I can't for the life of me find where (even when comparing to a working project), and the error message itself isn't providing any guidance. If anybody can offer any insights on how to get reports to render (or really just to have the api return something useful for the parameters call), I would greatly appreciate it.
Thanks!