Server-side Blazor template cleanups for Preview 4 (#9025)
* Rename Host.cshtml to _Host.cshtml * In Startup.cs, specify root component and selector explicitly so you can easily disable prerendering if desired * Remove unneccesary dependency on NewtonsoftJson package * Remove unnecessary MapRazorPages and make blank lines consistent * Rename "Services" subdirectory to "Data" * Remove favicon.ico (no longer needed since we switched to MapFallbackToPage * Revert MapComponentHub change due to reasons
This commit is contained in:
parent
edb91d0f4d
commit
3657a429eb
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Components.Prerendering" Version="${MicrosoftAspNetCoreMvcComponentsPrerenderingPackageVersion}" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Components.Prerendering" Version="${MicrosoftAspNetCoreMvcComponentsPrerenderingPackageVersion}" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="${MicrosoftAspNetCoreMvcNewtonsoftJsonPackageVersion}" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace RazorComponentsWeb_CSharp.Services
|
namespace RazorComponentsWeb_CSharp.Data
|
||||||
{
|
{
|
||||||
public class WeatherForecast
|
public class WeatherForecast
|
||||||
{
|
{
|
||||||
|
|
@ -2,7 +2,7 @@ using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace RazorComponentsWeb_CSharp.Services
|
namespace RazorComponentsWeb_CSharp.Data
|
||||||
{
|
{
|
||||||
public class WeatherForecastService
|
public class WeatherForecastService
|
||||||
{
|
{
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
@page "/fetchdata"
|
@page "/fetchdata"
|
||||||
@using RazorComponentsWeb_CSharp.Services
|
@using RazorComponentsWeb_CSharp.Data
|
||||||
@inject WeatherForecastService ForecastService
|
@inject WeatherForecastService ForecastService
|
||||||
|
|
||||||
<h1>Weather forecast</h1>
|
<h1>Weather forecast</h1>
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ using Microsoft.AspNetCore.HttpsPolicy;
|
||||||
#endif
|
#endif
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using RazorComponentsWeb_CSharp.Services;
|
using RazorComponentsWeb_CSharp.Data;
|
||||||
|
|
||||||
namespace RazorComponentsWeb_CSharp
|
namespace RazorComponentsWeb_CSharp
|
||||||
{
|
{
|
||||||
|
|
@ -20,11 +20,8 @@ namespace RazorComponentsWeb_CSharp
|
||||||
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddRazorPages()
|
services.AddRazorPages();
|
||||||
.AddNewtonsoftJson();
|
|
||||||
|
|
||||||
services.AddRazorComponents();
|
services.AddRazorComponents();
|
||||||
|
|
||||||
services.AddSingleton<WeatherForecastService>();
|
services.AddSingleton<WeatherForecastService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,6 +42,7 @@ namespace RazorComponentsWeb_CSharp
|
||||||
|
|
||||||
#if (RequiresHttps)
|
#if (RequiresHttps)
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
|
|
||||||
|
|
@ -52,9 +50,8 @@ namespace RazorComponentsWeb_CSharp
|
||||||
|
|
||||||
app.UseEndpoints(endpoints =>
|
app.UseEndpoints(endpoints =>
|
||||||
{
|
{
|
||||||
endpoints.MapRazorPages();
|
|
||||||
endpoints.MapComponentHub();
|
endpoints.MapComponentHub();
|
||||||
endpoints.MapFallbackToPage("/Host");
|
endpoints.MapFallbackToPage("/_Host");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 31 KiB |
Loading…
Reference in New Issue