Generating StiNetCoreViewer from the server and sending as s

Stimulsoft Reports.NET discussion
MichalCh
Posts: 17
Joined: Fri Sep 22, 2017 7:37 am

Re: Generating StiNetCoreViewer from the server and sending

Post by MichalCh »

Hello,

I've found what is the issue debugging the exception itself. The error as stated on top is from GetRequestUrl() method and this method (after a bit of my modifications) looks like:

Code: Select all

internal static string GetRequestUrl(ActionContext viewContext, string controller, bool relativeUrls, bool passQueryParams)
        {
            if (viewContext == null || (viewContext).HttpContext == null)
                return (string)null;
            HttpRequest request = (viewContext).HttpContext.Request;
            PathString pathBase = request.PathBase;
            // ISSUE: explicit reference operation
            string str1 = ((PathString)@pathBase).ToUriComponent();
            if (!relativeUrls)
            {
                string scheme = request.Scheme;
                string str2 = "://";
                HostString host = request.Host;
                // ISSUE: explicit reference operation
                string uriComponent = ((HostString)@host).ToUriComponent();
                string str3 = str1;
                str1 = scheme + str2 + uriComponent + str3;
            }
            if (!str1.EndsWith("/"))
                str1 += "/";

            var routeBase = viewContext.RouteData.Routers[1] as RouteBase;

            var routeColletion = viewContext.RouteData.Routers[1] as RouteCollection;

            using (IEnumerator<TemplateSegment> enumerator1 = (routeBase.ParsedTemplate.Segments).GetEnumerator())
            {
                while ((enumerator1).MoveNext())
                {
                    using (List<TemplatePart>.Enumerator enumerator2 = enumerator1.Current.Parts.GetEnumerator())
                    {
                        while (enumerator2.MoveNext())
                        {
                            TemplatePart current = enumerator2.Current;
                            str1 = !(current.Name == nameof(controller)) || string.IsNullOrEmpty(controller) ? (!(current.Name == "action") ? (!current.IsParameter ? str1 + current.Text : str1 + (viewContext).RouteData.Values[current.Name]) : str1 + "{action}") : str1 + controller;
                        }
                    }
                    if (!str1.EndsWith("/"))
                        str1 += "/";
                }
            }
            string str4 = str1.Substring(0, str1.Length - 1);
            if (passQueryParams)
                return str4 + (object)request.QueryString;
            return str4;
        }
Therefore I could easily see that the issue was that it couldn't find values from RouteData object passed as ActionContext in here to be specific

Code: Select all

private ActionContext GetActionContext(IServiceProvider serviceProvider)
        {
            return new ActionContext(this.HttpContext, RouteData, new ActionDescriptor());
        }
The RouteData object in my project is cleared out and therefore it throws an error before any javascript could override it. So I tried to bypass that by creating dummy classes/data and I've recreate the situation where I'm now and unfortunately I'm stuck with an error which you could see yourself in the uploaded project in .zip
Attachments
Samples-NET.Core-CSharp.rar
(7.34 MiB) Downloaded 631 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Generating StiNetCoreViewer from the server and sending

Post by Alex K. »

Hello,

We have added check on the empty RouteData, and new option for the component:

Code: Select all

        Server =
        {
            RouteTemplate = "/Stm/{action}"
        }
That should help. Also, please send us suggestions about this if you have.

Thank you.
MichalCh
Posts: 17
Joined: Fri Sep 22, 2017 7:37 am

Re: Generating StiNetCoreViewer from the server and sending

Post by MichalCh »

Hello,

Great, thank you. I will give it a try. I've updated the nuget package to 2017.2.3 but unfortunately the ServerOptions class is missing the RouteTemplate property. (In StiNetCoreDesignerOptions as well)

Code: Select all

#region Assembly Stimulsoft.Report.NetCore, Version=2017.2.3.0, Culture=neutral, PublicKeyToken=null
// C:\My\Path\.nuget\packages\stimulsoft.reports.netcore\2017.2.3\lib\netstandard1.6\Stimulsoft.Report.NetCore.dll
#endregion

using Newtonsoft.Json;

namespace Stimulsoft.Report.NetCore
{
    public class StiNetCoreViewerOptions
    {
        public StiNetCoreViewerOptions();

        public string Height { get; set; }
        public string Width { get; set; }
        public StiViewerTheme Theme { get; set; }
        public EmailOptions Email { get; set; }
        public string Localization { get; set; }
        public ToolbarOptions Toolbar { get; set; }
        public AppearanceOptions Appearance { get; set; }
        public ServerOptions Server { get; set; }
        public ActionOptions Actions { get; set; }
        public ExportOptions Exports { get; set; }

(...)

        public class ServerOptions
        {
            public ServerOptions();

            public string Controller { get; set; }
            public int RequestTimeout { get; set; }
            public bool UseRelativeUrls { get; set; }
            public bool PassQueryParametersForResources { get; set; }
        }

(...)     
Cheers
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: Generating StiNetCoreViewer from the server and sending

Post by Vladimir »

Hello,

This option will be added in version 2017.2.4

Thank you.
tayar
Posts: 30
Joined: Tue Sep 26, 2017 9:22 am

Re: Generating StiNetCoreViewer from the server and sending

Post by tayar »

Hi Vladimir,
Is there any estimation when the version 2017.2.4 will be released?

Thanks
Andrew
Posts: 4107
Joined: Fri Jun 09, 2006 3:58 am

Re: Generating StiNetCoreViewer from the server and sending

Post by Andrew »

Hello,

We expect the release of 2017.2.4 on November 14.

Thank you.
Post Reply