Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Commit a8a2a78

Browse files
author
Srushti Pasari94
committed
Moved Blazor server app to Blazor web app as per suggestion
1 parent 72e7d4a commit a8a2a78

File tree

5 files changed

+38
-38
lines changed

5 files changed

+38
-38
lines changed

src/eShopOnBlazor/App.razor

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
1-
<Router AppAssembly="typeof(Program).Assembly">
2-
<Found Context="routeData">
3-
<RouteView RouteData="routeData" DefaultLayout="typeof(MainLayout)" />
4-
</Found>
5-
<NotFound>
6-
<h1>Page not found</h1>
7-
<p>Sorry, but there's nothing here!</p>
8-
</NotFound>
9-
</Router>
1+
@inject IHostEnvironment Env
2+
3+
<!DOCTYPE html>
4+
<html lang="en">
5+
<head>
6+
<meta charset="utf-8" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8+
<title>Catalog manager (Blazor)</title>
9+
<base href="/" />
10+
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
11+
<link href="css/base.css" rel="stylesheet" />
12+
<link href="css/custom.css" rel="stylesheet" />
13+
<link href="css/site.css" rel="stylesheet" />
14+
</head>
15+
<HeadOutlet @rendermode="InteractiveServer" />
16+
<body>
17+
@* <app>@(await Html.RenderComponentAsync<HeadOutlet>(RenderMode.ServerPrerendered))</app> *@
18+
<Routes @rendermode="InteractiveServer" />
19+
20+
<script src="_framework/blazor.web.js"></script>
21+
</body>
22+
</html>

src/eShopOnBlazor/Pages/_Host.cshtml

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/eShopOnBlazor/Program.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using eShopOnBlazor.Models;
1+
using eShopOnBlazor.Models;
22
using eShopOnBlazor.Models.Infrastructure;
33
using eShopOnBlazor.Services;
44
using log4net;
@@ -10,7 +10,7 @@
1010
// add services
1111

1212
builder.Services.AddRazorPages();
13-
builder.Services.AddServerSideBlazor();
13+
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
1414

1515
if (builder.Configuration.GetValue<bool>("UseMockData"))
1616
{
@@ -49,11 +49,10 @@
4949

5050
app.UseRouting();
5151

52-
app.UseEndpoints(endpoints =>
53-
{
54-
endpoints.MapBlazorHub();
55-
endpoints.MapFallbackToPage("/_Host");
56-
});
52+
app.UseAntiforgery();
53+
54+
app.MapRazorComponents<App>()
55+
.AddInteractiveServerRenderMode();
5756

5857
ConfigDataBase(app);
5958

src/eShopOnBlazor/Routes.razor

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Router AppAssembly="typeof(Program).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="routeData" DefaultLayout="typeof(MainLayout)" />
4+
</Found>
5+
<NotFound>
6+
<h1>Page not found</h1>
7+
<p>Sorry, but there's nothing here!</p>
8+
</NotFound>
9+
</Router>

src/eShopOnBlazor/_Imports.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
@using eShopOnBlazor.Services
1010
@using eShopOnBlazor.Shared
1111
@using eShopOnBlazor.ViewModel
12+
@using static Microsoft.AspNetCore.Components.Web.RenderMode

0 commit comments

Comments
 (0)