Blazor.Printing icon indicating copy to clipboard operation
Blazor.Printing copied to clipboard

script.js cannot be loaded when Razor component is emended in an Razor page [Blazor Server]

Open wolfgangschneider opened this issue 5 years ago • 3 comments

Hi

the Blazor.Print works well in an pure Blazor App. I am adding Blazor to an existing MVC / Rzor pages Project. When calling PrintingService.Print in an Razor component and t5his razor component is embedder in an razor Page the script.js could not be doinloaded to the server.

  • On a pure Blazor project the ImportModule() function try to download the script.js file from _content/Append.Blazor.Printing/scripts.js

  • if the Razor component is embedded the ImportModule() function try to download the script.js file from XXXXRazorPage_content/Append.Blazor.Printing/scripts.js

wolfgangschneider avatar Nov 18 '20 13:11 wolfgangschneider

// this could help
internal async ValueTask ImportModule() { // module = await jsRuntime.InvokeAsync<IJSObjectReference>("import", "./_content/Append.Blazor.Printing/scripts.js"); module = await jsRuntime.InvokeAsync<IJSObjectReference>("import", $"{this.navigationManager.BaseUri}_content/Append.Blazor.Printing/scripts.js");

    }

wolfgangschneider avatar Dec 11 '20 12:12 wolfgangschneider

@wolfgangschneider Interesting, is there some general guidance on this in the Blazor Docs? Because this might cause problems elsewehere. If you like PR's are welcome, don't forget to create a MVC example so we can test it later on.

vertonghenb avatar Dec 13 '20 13:12 vertonghenb

Hi,

Is this error related to this problem?

image

Im not in a pure Blazor App indeed.

Thanks

DrTekno avatar Aug 13 '21 10:08 DrTekno