Re: Generating StiNetCoreViewer from the server and sending
Posted: Wed Nov 01, 2017 3:15 pm
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:
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
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
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;
}
Code: Select all
private ActionContext GetActionContext(IServiceProvider serviceProvider)
{
return new ActionContext(this.HttpContext, RouteData, new ActionDescriptor());
}