asp.net core UseResponseCaching problem

Stimulsoft Reports.WEB discussion
Post Reply
giorgizek
Posts: 5
Joined: Fri Jan 21, 2011 10:49 am

asp.net core UseResponseCaching problem

Post by giorgizek »

Hello,

There is display problem when using response cache
Startup.cs

Code: Select all

 app.UseResponseCaching();

Controller

Code: Select all

public class ReportsController : Controller
 {

        public IActionResult Index(string idLink = null)
        {
            return View("~/Views/Report/Index.cshtml");
        }


        public IActionResult ViewerEvent()
        {
            return StiNetCoreViewer.ViewerEventResult(this);
        }


        //[HttpGet("~/[action]")]
        public async Task<IActionResult> GetReport(string idLink = null)
        {
            var report = await InternalGetReportAndBindAsync();
            return StiNetCoreViewer.GetReportResult(this, report);
        }
}
index.chtml

Code: Select all

@using Stimulsoft.Report.Mvc;
@{
    ViewData["Title"] = "Report";
    Layout = "_LayoutPrint";
}

@Html.StiNetCoreViewer(new StiNetCoreViewerOptions
{
    Localization = "Localization/ka.xml",
    Server = new StiNetCoreViewerOptions.ServerOptions
    {
        RouteTemplate = "Reports/{action}",
    },
    Actions =
    {
        GetReport = "GetReport",
        ViewerEvent =  "ViewerEvent",
    },
    Appearance =
    {
        FullScreenMode = true,
    },
    Toolbar =
    {
        ShowFullScreenButton = false,
    },
})
Attachments
01.png
01.png (87.04 KiB) Viewed 2885 times
Lech Kulikowski
Posts: 7341
Joined: Tue Mar 20, 2018 5:34 am

Re: asp.net core UseResponseCaching problem

Post by Lech Kulikowski »

Hello,

We made changes in our test project, which you specified, and couldn't reproduce the issue. Please send a test project or a modified example of a project from those located on GitHub:
https://github.com/stimulsoft/Samples-N ... MVC-CSharp

Thank you.
giorgizek
Posts: 5
Joined: Fri Jan 21, 2011 10:49 am

Re: asp.net core UseResponseCaching problem

Post by giorgizek »

Here is test project
Attachments
Test.rar
(1.46 MiB) Downloaded 181 times
Lech Kulikowski
Posts: 7341
Joined: Tue Mar 20, 2018 5:34 am

Re: asp.net core UseResponseCaching problem

Post by Lech Kulikowski »

Hello,

We analyzed your project and reproduced the error when using query caching. In this case, the error occurs because the same (cached) response from the server side is returned for the ViewerEvent action, although the URL of the Query String is different. You need to exclude the caching of the ViewerEvent action, or add the following URL to the exceptions: "stiweb_component", "stiweb_action", "stiweb_data"

Thank you.
giorgizek
Posts: 5
Joined: Fri Jan 21, 2011 10:49 am

Re: asp.net core UseResponseCaching problem

Post by giorgizek »

OK,

How can I exclude idLink param from ViewerEvent?
<script type="text/javascript" src="/Reports/ViewerEvent?idLink=0f07a6dc-e6bd-476b-ba44-0b5b4878ae39&stiweb_component=Viewer&stiweb_action=Resource&stiweb_data=scripts&stiweb_theme=Office2013WhiteBlue&stiweb_loc=TG9jYWxpemF0aW9uL2thLnhtbA%3d%3d&stiweb_cachemode=cache&stiweb_version=2019.1.1">
Lech Kulikowski
Posts: 7341
Joined: Tue Mar 20, 2018 5:34 am

Re: asp.net core UseResponseCaching problem

Post by Lech Kulikowski »

Hello,

To remove idLink from requests, you can set the following parameter in the Server section:
PassQueryParametersForResources = false

For removing idLink from all viewer requests, you can use the following code on the page after it initialization:

Code: Select all

<script>
    function removeParam(key, sourceURL) {
        var rtn = sourceURL.split("?")[0],
            param,
            params_arr = [],
            queryString = (sourceURL.indexOf("?") !== -1) ? sourceURL.split("?")[1] : "";
        if (queryString !== "") {
            params_arr = queryString.split("&");
            for (var i = params_arr.length - 1; i >= 0; i -= 1) {
                param = params_arr[i].split("=")[0];
                if (param === key) {
                    params_arr.splice(i, 1);
                }
            }
            rtn = rtn + "?" + params_arr.join("&");
        }
        return rtn;
    }

    jsNetCoreViewer.options.requestUrl = removeParam("idLink", jsNetCoreViewer.options.requestUrl);
    jsNetCoreViewer.options.requestAbsoluteUrl = removeParam("idLink", jsNetCoreViewer.options.requestAbsoluteUrl);
    jsNetCoreViewer.options.requestStylesUrl = removeParam("idLink", jsNetCoreViewer.options.requestStylesUrl);

</script>
Thank you.
giorgizek
Posts: 5
Joined: Fri Jan 21, 2011 10:49 am

Re: asp.net core UseResponseCaching problem

Post by giorgizek »

Thanks
Lech Kulikowski
Posts: 7341
Joined: Tue Mar 20, 2018 5:34 am

Re: asp.net core UseResponseCaching problem

Post by Lech Kulikowski »

Hello

We are always glad to help you!
Please let us know if you need any additional help.

Thank you.
Post Reply