You could not add the authentication for export and image rendering requests from the Report Viewer and Report Designer. So, you have to ignore the authentication for the GetResource
and PostFormReportAction
methods using the [AllowAnonymous]
attribute.
Regarding security, you will not have any issues in the aspect of security by ignoring the authentication for this GetResource
and PostFormReportAction
requests.
These requests are used to retrieve the file format content from the server and used with our control based on the framework suggestion to have better experience in usability in downloads and avoid the delay of rendering images with reports.
These requests will be used at the time of exporting and image rendering only, this cannot be used once again by others. This approach is similar to the Amazon Simple Storage Service (Amazon S3) how they are providing access to share the private files,
You can get more details of the implementation approach from these steps,
You can find the following code reference for using the [AllowAnonymous]
attribute and sample from this link.
[Authorize]
[Route("api/[controller]/[action]/{id?}")]
public class ReportApiController : ControllerBase, IReportController
{
…….
…….
[ActionName("GetResource")]
[AcceptVerbs("GET")]
[AllowAnonymous]
public object GetResource(ReportResource resource)
{
return ReportHelper.GetResource(resource, this, _cache);
}
[HttpPost]
[AllowAnonymous]
public object PostFormReportAction()
{
return ReportHelper.ProcessReport(null, this, this._cache);
}
…….
…….
}