GithubHelp home page GithubHelp logo

Comments (11)

netclectic avatar netclectic commented on May 22, 2024 1

The problem is resolved with v2.0.7.

Thanks!

from localstorage.

chrissainty avatar chrissainty commented on May 22, 2024 1

I've now pushed a new version of the package which no longer needs a JavaScript file. This should completely remove the issue. Please give it a go and let me know if you have any issues.

from localstorage.

dinonovak avatar dinonovak commented on May 22, 2024

I can confirm that upgrading to Blazor Preview7 requires manual add on script tag to function properly.

from localstorage.

chrissainty avatar chrissainty commented on May 22, 2024

@netclectic - Is this still the case with v2.0.7?
@dinonovak - Which version are you using and is that client-side Blazor or server-side?

from localstorage.

chrissainty avatar chrissainty commented on May 22, 2024

Great stuff. Iā€™m going to go ahead and close the issue as things seem to be working as expected now.

from localstorage.

joshhubers avatar joshhubers commented on May 22, 2024

I'm still receiving this issue in the browser and updated the _Host file to:

<script src="_content/Blazored.LocalStorage/blazored-localstorage.js"></script>

Running the the latest LocalStorage - 2.0.11

Running core preview8 in docker image - core/sdk:3.0.100-preview8-disco

I get a 404 for the js file in the browser.

Thanks!

from localstorage.

chrissainty avatar chrissainty commented on May 22, 2024

@joshhubers Have you tried a clean/re-build/clear of browser cache. I've had a lot of people have this issue and one of those sorts it out.

There are some issues with the new Razor Class Library right now. So it might be best to just manually copy the JS file from this repo into your solution.

from localstorage.

thild avatar thild commented on May 22, 2024

I have a blazorwasm app but served by a webapi. In order to get Blazored.LocalStorage working I had to add this to Blazored.LocalStorage.csproj.

  <ItemGroup>
    <!-- .js/.css files will be referenced via <script>/<link> tags; other content files will just be included in the app's 'dist' directory without any tags referencing them -->
    <EmbeddedResource Include="wwwroot\**\*.js" LogicalName="blazor:js:%(RecursiveDir)%(Filename)%(Extension)" />
    <EmbeddedResource Include="wwwroot\**\*.css" LogicalName="blazor:css:%(RecursiveDir)%(Filename)%(Extension)" />
    <EmbeddedResource Include="wwwroot\**" Exclude="**\*.js;**\*.css" LogicalName="blazor:file:%(RecursiveDir)%(Filename)%(Extension)" />
  </ItemGroup>

This will copy all embedded resources to bin/Debug/netstandard2.0/dist/_content/Blazored.LocalStorage/* so Kestrel can serve.
Doing this the tag <script src="_content/Blazored.LocalStorage/blazored-localstorage.js"></script> is added automatically by Blazor in index.html.
This not affect BlazorClientSide sample app.

I create a pull request #29.

from localstorage.

chrissainty avatar chrissainty commented on May 22, 2024

@thild This code is now legacy and not the way class libraries need to work going forward. As of right now the situation is this. Both JS and CSS in Razor Class libraries gets included in host projects correctly at development time. If you're not seeing this then see my comment above explaining the steps to go through to get things working.

However, both for client-side Blazor and server-side Blazor there is an issue with publishing which stop static assets being included correctly, this is going to be fixed in Preview 9 (I hope!).

from localstorage.

thild avatar thild commented on May 22, 2024

@chrissainty Thanks for clarification. Investigating further I found that is a known Blazor issue dotnet/aspnetcore#13122. The workaround mentioned there is run the project in development environment.
ASPNETCORE_ENVIRONMENT=Development dotnet run
or setup Properties/launchSettings.json

{
    "profiles": {
        "ServerProjectName": {
            "commandName": "Project",
            "launchBrowser": true,
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Development"
            },
            "applicationUrl": "http://localhost:5000/"
        }
    }
}

However, you might consider keeping the EmbeddedResource workaround in .cpsproj until the Blazor team resolves this issue, as this does not affect the new way of referencing static assets.

from localstorage.

thild avatar thild commented on May 22, 2024

I tried the new version. Removed reference to js and everything is working. Nice solution. Thanks.

from localstorage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.