I have an interesting issue in which reports will not load if the .NET Core app is deployed to a custom relative URL. For example, it works with http://localhost:50754 but not with http://localhost:50754/testsite/ I have found a very quick way to reproduce the issue. As an example, I am using the SimpleList demo (https://demo.stimulsoft.com/#Net/SimpleList). To run it locally, I published it from the Designer without making any changes to it using the .NET Core and Angular configuration. Running it in Visual Studio and debugging it in IIS Express within Visual Studio works fine. However, it breaks when I make this change:
- Right-click on the NetCoreAngularApplication project in the solution explorer.
- Click on Properties.
- In the Properties window that comes up, on the left side menu, click on Debug.
- Under Web Server Settings at the bottom, the App URL is set to "http://localhost:50754". Change this to anything different like "http://localhost:50754/testsite"
- Run it with IIS Express again. It will deploy the site to http://localhost:50754/testsite. However, when you navigate to the Stimulsoft Report section on the side menu of the webpage, the report does not display. Looking at the debug tools, it is trying to load http://localhost:50754/api/viewer?... from the base URL but it is ignoring the "testsite" portion of the URL. So this is throwing a 404 error on /api/viewer/ itself because http://localhost:50754/api/viewer cannot be found because it really should be http://localhost:50754/testsite/api/viewer.
Is there a way to make it not try to load /api/viewer/ from the base URL but rather the relative URL? I have a workaround that works but was curious if there was more of a formal solution. My workaround is to force the HttpContext PathBase into the CoreRequest object like this:
In ViewerController.cs
Code: Select all
// Setting the required options on the server side
var requestParams = StiNetCoreViewer.GetRequestParams(this);
// -- *** This is one of two lines of code that makes it work: Where the HttpContext that has the PathBase and Path is of type Microsoft.AspNetCore.Http.HttpContext.
requestParams.HttpContext.Request.CoreRequest.Path = HttpContext.Request.PathBase + HttpContext.Request.Path;
if (requestParams.Action == StiAction.Undefined)
{
var options = new StiNetCoreViewerOptions();
// -- *** This is the second line of code to make it work. Instead of using GetScriptsResult() with the 'this' controller parameter, use it with the requestParams parameter.
return StiNetCoreViewer.GetScriptsResult(requestParams, options);
}
return StiNetCoreViewer.ProcessRequestResult(this);
Thanks again!
-Emanuel