question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to get full path of isolated JS/CSS assets for Blazor

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

The documentation about JavaScript isolated modules says to call import to to get isolated JS reference:

protected override async Task OnAfterRenderAsync(bool firstRender)
{
    if (firstRender)
    {
        module = await JS.InvokeAsync<IJSObjectReference>("import", 
            "./scripts.js");
    }
}

The problem is the path of the JS file. Assuming we have Pages/CallJsExample6.razor and Pages/CallJsExample6.razor.js javascript module.

Then we should call await JS.InvokeAsync<IJSObjectReference>("import", "./Pages/CallJsExample6.razor.js").

Once we move CallJsExample6.razor to the external class library, it will have a path like ./_content/ExternalAssemblyName/Components/CallJsExample6.razor.js.

So, the question is whether it’s possible to resolve asset’s path after project publishing in runtime?

Describe the solution you’d like

Something like var path = Resolver.GetContentPath('./Pages/CallJsExample6.razor.js');

Additional context

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
msftbot[bot]commented, Jan 22, 2022

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.

0reactions
sergeyzwezdincommented, Jan 22, 2022

Actually, the problem is not solved, not sure why it’s closed 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.NET Core Blazor CSS isolation
Learn how CSS isolation scopes CSS to Razor components, which can simplify CSS and avoid collisions with other components or libraries.
Read more >
c# - Embed JavaScript files inside a .NET class library for ...
The path segment for the current directory (./) is required in order to create the correct static asset path to the JS file....
Read more >
Use CSS isolation in your Blazor projects - Dave Brock
Reminder: CSS isolation is a build-time step​​ To support isolation, Blazor rewrites all the CSS selectors during the build process. This makes ...
Read more >
What is Blazor CSS isolation? How do you enable it for ...
razor,” create a file alongside the component named “Isolate.razor.css.” The Isolate.razor.css file is placed in the same folder as the Isolate.razor component.
Read more >
Getting a file path from a user : r/Blazor
Yes this would work, so creating a component which uses Directory.GetFiles for the share path and displaying them as a listing?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found