Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IJSObjectReference module import path error #47430

Closed
1 task done
hannespreishuber opened this issue Mar 27, 2023 · 2 comments
Closed
1 task done

IJSObjectReference module import path error #47430

hannespreishuber opened this issue Mar 27, 2023 · 2 comments
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved

Comments

@hannespreishuber
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

the Blazor Server app runs in two diffrent enviroments (dev and production). I have a component which must use some JS - no library

module = await JSRuntime.InvokeAsync<IJSObjectReference>("import", "./scripts/bankeinzugrazor.js");
make wring path in production (url site/pp/)

https://...site/pp/ppscripts/bankeinzugrazor.js

JavaScript can not be load. 404 as path should be pp/scripts

Other ./ path issues are solved by
<base href="~/pp" />
or in more generic way by

    <environment include="Development">  
            <base href="~/" />   
    </environment>   
    <environment exclude="Development">  
        <base href="~/pp" />  
    </environment>

also tried to use app.UsePathBase, but docu says obsolete in 6?

Expected Behavior

korrekt path to js

Steps To Reproduce

Visual Studio Blazor Server projekt
place Js in wwwroot scripts
load Module from .razor OnAfterRenderAsync

Exceptions (if any)

No response

.NET Version

7.0.202 /6

Anything else?

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Mar 27, 2023
@javiercn
Copy link
Member

@hannespreishuber thanks for contacting us.

Your base path is incorrect. It needs to end with / as in <base href="~/pp/" />. Otherwise, the browser interprets it as ~/ (removes the last segment as its considered "a file").

@javiercn javiercn added feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly question ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. labels Mar 27, 2023
@ghost ghost added the Status: Resolved label Mar 27, 2023
@ghost
Copy link

ghost commented Mar 28, 2023

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

@ghost ghost closed this as completed Mar 28, 2023
@dotnet dotnet locked as resolved and limited conversation to collaborators Apr 27, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved
Projects
None yet
Development

No branches or pull requests

2 participants