Hi,
I am looking at using Telerik Reporting in ASP.NET MVC and have run into a problem in using the InstanceReportSource.
When loading a basic report into the report viewer, it shows 'Bad Request' (see attached screenshot). I have profiled this using Fiddler and traced this down to a problem in the REST service. On the request '/api/Reports/clients/113112-3522/parameters' it returns the response '{"message":"Missing report name"}'. I have tried setting various name parameters in the InstanceReportSource and on the report, but the problem still occurs.
I have tried exactly the same report in the same project using a TypeReportSource and it works fine! However, I cannot use this because I need to get access to the report to bind the data at runtime. I cannot specify any data sources in the report because the source of data is not known then. The data source must be set programmatically at runtime.
I have created a basic ASP.NET MVC project and am setting the report in the HomeController as follows...
public class HomeController : Controller
{
public ActionResult Index()
{
// THIS DOES NOT WORK...
ViewData["ReportSource"] = CreateInstanceReportSource();
// THIS WORKS...
//ViewData["ReportSource"] = CreateTypeReportSource();
return View();
}
private ReportSource CreateTypeReportSource()
{
return new TypeReportSource()
{
TypeName = "TestTelerikReporting.Reports.Report1, TestTelerikReporting"
};
}
private ReportSource CreateInstanceReportSource()
{
return new InstanceReportSource()
{
ReportDocument = new Report1()
};
}
}
This is the view for the report viewer...
@(Html.TelerikReporting().ReportViewer()
.Id("reportViewer1")
.ServiceUrl(Url.Content("~/api/Reports/"))
.TemplateUrl(Url.Content("~/ReportViewer/templates/telerikReportViewerTemplate.html"))
.ReportSource((Telerik.Reporting.ReportSource)ViewData["ReportSource"])
.ViewMode(ViewModes.INTERACTIVE)
.ScaleMode(ScaleModes.SPECIFIC)
.Scale(1.0)
.PersistSession(true)
)
I have read this sample which states the InstanceReportSource should be used...
http://www.telerik.com/forums/yet-another-reportsource-to-instancereportsource
However, this answer seems to contradict this approach and does not recommend using an InstanceReportSource...
http://www.telerik.com/forums/asp-net-mvc---telerik-reporting-error-gt-api-reports-clients-returns-missing-report-name
What is the recommended way of getting an instance of a report in an ASP.NET MVC application, to be able to bind data to it? Any assistance is much appreciated!
Kind Regards,
James
I am looking at using Telerik Reporting in ASP.NET MVC and have run into a problem in using the InstanceReportSource.
When loading a basic report into the report viewer, it shows 'Bad Request' (see attached screenshot). I have profiled this using Fiddler and traced this down to a problem in the REST service. On the request '/api/Reports/clients/113112-3522/parameters' it returns the response '{"message":"Missing report name"}'. I have tried setting various name parameters in the InstanceReportSource and on the report, but the problem still occurs.
I have tried exactly the same report in the same project using a TypeReportSource and it works fine! However, I cannot use this because I need to get access to the report to bind the data at runtime. I cannot specify any data sources in the report because the source of data is not known then. The data source must be set programmatically at runtime.
I have created a basic ASP.NET MVC project and am setting the report in the HomeController as follows...
public class HomeController : Controller
{
public ActionResult Index()
{
// THIS DOES NOT WORK...
ViewData["ReportSource"] = CreateInstanceReportSource();
// THIS WORKS...
//ViewData["ReportSource"] = CreateTypeReportSource();
return View();
}
private ReportSource CreateTypeReportSource()
{
return new TypeReportSource()
{
TypeName = "TestTelerikReporting.Reports.Report1, TestTelerikReporting"
};
}
private ReportSource CreateInstanceReportSource()
{
return new InstanceReportSource()
{
ReportDocument = new Report1()
};
}
}
This is the view for the report viewer...
@(Html.TelerikReporting().ReportViewer()
.Id("reportViewer1")
.ServiceUrl(Url.Content("~/api/Reports/"))
.TemplateUrl(Url.Content("~/ReportViewer/templates/telerikReportViewerTemplate.html"))
.ReportSource((Telerik.Reporting.ReportSource)ViewData["ReportSource"])
.ViewMode(ViewModes.INTERACTIVE)
.ScaleMode(ScaleModes.SPECIFIC)
.Scale(1.0)
.PersistSession(true)
)
I have read this sample which states the InstanceReportSource should be used...
http://www.telerik.com/forums/yet-another-reportsource-to-instancereportsource
However, this answer seems to contradict this approach and does not recommend using an InstanceReportSource...
http://www.telerik.com/forums/asp-net-mvc---telerik-reporting-error-gt-api-reports-clients-returns-missing-report-name
What is the recommended way of getting an instance of a report in an ASP.NET MVC application, to be able to bind data to it? Any assistance is much appreciated!
Kind Regards,
James