Page 1 of 1

asp.net core UseResponseCaching problem

Posted: Sun Feb 03, 2019 5:09 pm
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,
    },
})

Re: asp.net core UseResponseCaching problem

Posted: Mon Feb 04, 2019 2:00 pm
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.

Re: asp.net core UseResponseCaching problem

Posted: Tue Feb 05, 2019 9:34 am
by giorgizek
Here is test project

Re: asp.net core UseResponseCaching problem

Posted: Wed Feb 06, 2019 10:28 am
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.

Re: asp.net core UseResponseCaching problem

Posted: Wed Feb 06, 2019 1:53 pm
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">

Re: asp.net core UseResponseCaching problem

Posted: Thu Feb 07, 2019 9:02 am
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.

Re: asp.net core UseResponseCaching problem

Posted: Fri Feb 08, 2019 8:56 am
by giorgizek
Thanks

Re: asp.net core UseResponseCaching problem

Posted: Fri Feb 08, 2019 10:25 am
by Lech Kulikowski
Hello

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

Thank you.