Closed rzechu closed 10 months ago
Ok I finally resolved problem. There was additional uneccesary ASP.NETCore nuget packages in my projects
I removed all and now it looks that: MyApp.Shared.csproj
...
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="MudBlazor" Version="6.8.0" />
</ItemGroup>
...
MyApp.Web.csproj
...
<ItemGroup>
<Compile Remove="Shared\**" />
<Content Remove="Shared\**" />
<EmbeddedResource Remove="Shared\**" />
<None Remove="Shared\**" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyApp.Shared\MyApp.Shared.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0" />
<PackageReference Include="MudBlazor" Version="6.8.0" />
</ItemGroup>
...
I moved my data for both projects from Pages and Shared to Components\Pages Components\Shared Components\App.razor Components\Route.razor
Changed Route.razor to following (check 1 line )
<Router AppAssembly="@typeof(App).Assembly" AdditionalAssemblies="new[] {typeof(MyApp.Shared.Components.Shared.MainLayout).Assembly, typeof(Program).Assembly }">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
And in Program.cs i changed
app.MapRazorComponents<MyApp.Web.Components.App>()
.AddInteractiveServerRenderMode()
To
app.MapRazorComponents<MyApp.Web.Components.App>()
.AddInteractiveServerRenderMode()
.AddAdditionalAssemblies(new System.Reflection.Assembly[] { typeof(MyApp.Shared.Components.Shared.MainLayout).Assembly });
Looks like everything even MudBlazor working corectly now!
@rzechu Do you have any idea of what precisely made it work? (I have the same issue with blazor wasm/server hosted that I am trying to upgrade) (HTTP GET / responded 404 in 74.9575 ms)
@erikthysell I posted my thought above.
Server/server-side: Interactive server-side rendering (interactive SSR) of a Blazor Web App. The Program file is Program.cs of the server project. Blazor script start configuration is found in the App component (Components/App.razor). Only routable Interactive Server render mode components with an @page directive are placed in the Components/Pages folder. Non-routable shared components are placed in the server project's Components folder. Create custom folders based on component functionality as needed. https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/routing?view=aspnetcore-8.0
Check Program.cs my two last quotes from previous post and Routes.razor
@rzechu seems you were able to resolve the issues.
@erikthysell if you are running into issues, please file a separate issue with concrete details, as otherwise we'll lose track of it, and details from different issues get confused.
Hi all, add this to your program.cs (in a Blazor Web App) so that the @page="/" in the Shared library is found at compile time. "Map Razor Components" If your app is not working, check if it's a 404 or 500 error.
app.MapRazorComponents
This is among @rzechu list of changes.
Hi all, add this to your program.cs (in a Blazor Web App) so that the @page="/" in the Shared library is found at compile time. "Map Razor Components" If your app is not working, check if it's a 404 or 500 error.
app.MapRazorComponents() .AddAdditionalAssemblies(new System.Reflection.Assembly[] { typeof(MyApp.Shared.Components.Shared.MainLayout).Assembly });
This is among @rzechu list of changes.
Thank you. I posted my solution 3posts above and the thing you mentioned is included in last one quote
Is there an existing issue for this?
Describe the bug
I have try to upgrade my Blazor Server App from .NET 6 to .NET 8 i guess I followed instructions from: https://learn.microsoft.com/en-us/aspnet/core/migration/70-80?view=aspnetcore-8.0&tabs=visual-studio#adopt-all-blazor-web-app-conventions
Comparing my after changes files with files from new created Blazor Web App project and files from: https://github.com/danroth27/Net8BlazorServer/tree/main
I am using Shared project (due to using project for Native)
It used to work in .NET 6
After running application I have no runtime/compilation errors - just error 404 after app startup I am using Mudblazor too but I doubt problem is here. I guess its even before app fully startup.
App.razor
_Imports.razor
Routes.razor
Program.cs
I have tried add to Program.cs
app.UseStatusCodePagesWithRedirects("/404");
And _404.razorTo both MyApp.Web.Pages MyApp.Shared.Pages
It automatically makes redtrection to http://localhost:xxxx/404 but it doesn't shows any page too just
Expected Behavior
Page is running or atleast run and throwing any error in compliation/runtime
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
8.0
Anything else?
No response