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

Why blazor app doesn't work when i change root to folder “_framework” #15622

Closed
PeskovV opened this issue Sep 14, 2018 · 2 comments
Closed
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@PeskovV
Copy link

PeskovV commented Sep 14, 2018

I change my base href in index.html: was href="/" has become href="/schedule/"

Also i change Configure:

 app.UseStaticFiles();
            app.UseStaticFiles(new StaticFileOptions()
            {
                FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(),@"Schedule.Client", @"dist")),
                RequestPath = new PathString("/schedule")
            });

Here located my files

Here located my files:

css, js, resources work good, but _framework which includes wasm files and doesn't work correct.

index.html:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width">
    <title>Schedule</title>
    <link rel="icon" href="css/Resources/icon_title.png" />
    <base href="/schedule/" />
    <link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" crossorigin="anonymous">
    <link href="css/site.css" rel="stylesheet" />
    <link href="css/btnstyle.css" rel="stylesheet" />
    <script src="js/SetScroll.js"></script>

</head>
<body>
    <app>
        <div id="demo" style="margin:auto; top:30px;">
            <img src="css/Resources/logo-fin.png" />
            <div class="circle fas fa-spinner"></div>
        </div>
    </app>

    <script src="_framework/blazor.webassembly.js"></script>
    <script defer src="https://use.fontawesome.com/releases/v5.2.0/js/all.js" crossorigin="anonymous"></script>
</body>
</html>

When I start my app, I get error
enter image description here

When i use href="/", all is correct

What could be wrong?
Thanks!

Update

I have found the same problem and solution, but there is used a Azure CLI:
https://anthonychu.ca/post/blazor-azure-storage-static-websites/

enter image description here

@SteveSandersonMS
Copy link
Member

At the very least, you'd need to move your UseBlazor call into a block like:

app.Map("/schedule", subdirApp =>
{
    subdirApp.UseBlazor<Startup>();
});

... so that the UseBlazor middleware is operating within the new root.

There might be more as well - I'm not in a position to actually test this right now. However you can find a working example of a Blazor app hosted in a subdirectory at https://github.com/aspnet/Blazor/blob/master/test/testapps/TestServer/Startup.cs#L41

@PeskovV
Copy link
Author

PeskovV commented Sep 17, 2018

@SteveSandersonMS Thank you, very much!

@mkArtakMSFT mkArtakMSFT transferred this issue from dotnet/blazor Oct 27, 2019
@mkArtakMSFT mkArtakMSFT added area-blazor Includes: Blazor, Razor Components and removed area-blazor Includes: Blazor, Razor Components labels Oct 27, 2019
@dotnet dotnet locked as resolved and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

No branches or pull requests

3 participants