Dear supporting team,
First of all, I apologize for the typo in the title. I can't fix it
I used Telerik reporting to design the report.
But I was facing a problem. I can not or don't know how to get the session value or cookie value in the ASP.NET Core Web App project.
The way I do it is:
- Create a new report by Report Designer
- Create an HTML page, and add the following code
<script type="text/javascript">
$(document).ready(function () {
var au = document.cookie.split('=');
var uname = au[1];
var urlParams = new URLSearchParams(window.location.search);
var rp = urlParams.get('r');
$("#reportViewer1")
.telerik_ReportViewer({
serviceUrl: "/api/reports",
reportSource: {
report: "INV_ADJUSTMENT_DETAIL.trdx",
parameters: { user_name: uname, report: rp }
},
viewMode: telerikReportViewer.ViewModes.INTERACTIVE,
scaleMode: telerikReportViewer.ScaleModes.SPECIFIC,
scale: 1.0,
enableAccessibility: false,
sendEmail: { enabled: false },
ready: function () {
},
});
});
</script>
And in the Program.cs
.....
builder.Services.TryAddSingleton<IReportServiceConfiguration>(sp => new ReportServiceConfiguration
{
ReportingEngineConfiguration = sp.GetService<IConfiguration>(),
HostAppId = "Html5ReportViewerDemo",
Storage = new FileStorage(),
ReportSourceResolver = new CustomReportSourceResolver()
});
builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
builder.Services.AddHttpContextAccessor();
builder.Services.AddDistributedMemoryCache();
builder.Services.AddSession(session =>
{
session.IdleTimeout = TimeSpan.FromMinutes(60);
session.Cookie.HttpOnly = true;
session.Cookie.IsEssential = true;
});
.....
In the report designer, how can I use the value in reportSource -> parameters?
Is there a possible solution for this? please help advise.
Visual Studio version: Microsoft Visual Studio Professional 2022
Framework: .Net 6.0
Telerik packages:
- Telerik.Reporting v.17.0.23.315;
- Telerik.Reporting.OpenXmlRendering v.17.0.23.315;
- Telerik.Reporting.Services.AspNetCore 17.0.23.315
Many thanks,
Dinh Phong