Beispiel #1
0
        public Task <string> RenderHtmlPageAsync(HttpContext context)
        {
            var requestFeature        = context.Features.Get <IHttpRequestFeature>();
            var unencodedPathAndQuery = requestFeature.RawTarget;

            var request = context.Request;
            var baseUrl = $"{request.Scheme}://{request.Host}";

            var props = new RenderFuncProps()
            {
                requestUrl    = unencodedPathAndQuery,
                baseUrl       = baseUrl,
                assets        = _assesResolver.ResolveAssets(context),
                inlineScripts = new[]
                {
                    new InlineScript()
                    {
                        position = "top",
                        script   = _telemetryProvider.GetCodeSnippet(),
                    },
                },
            };

            var objectArgs = new object[] { props };

            return(_jsService.InvokeFromFileAsync <JsonElement>(_options.Value.SsrScriptPath, "default", objectArgs)
                   .ContinueWith(task => task.Result.GetProperty("html").GetString()));
        }