Template updates (#185)
* Remove unnecessary <OutputType>Exe</OutputType> from templates * Rename BlazorHosted.* projects to BlazorHosted.CSharp.(Client|Server) * Add empty BlazorHosted.CSharp.Shared, referenced from the two other BlazorHosted.CSharp.* projects * Have BlazorHosted.CSharp.Client fetch data from BlazorHosted.CSharp.Server * Update templates to Blazor 0.0.5-preview1-10037 * Make date handling consistent across the templates * Enable response compression in "hosted" template * Enable response compression in dev server * Simplify template app code using new namespace arrangement * Fix project name in hosted template
This commit is contained in:
parent
4bd3cd98d6
commit
f3b10bfa4c
37
Blazor.sln
37
Blazor.sln
|
|
@ -76,15 +76,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "templates", "templates", "{
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorStandalone.CSharp", "src\Microsoft.AspNetCore.Blazor.Templates\content\BlazorStandalone.CSharp\BlazorStandalone.CSharp.csproj", "{A092FA91-856B-4ACA-B1C2-10BDBA366185}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorStandalone.CSharp", "src\Microsoft.AspNetCore.Blazor.Templates\content\BlazorStandalone.CSharp\BlazorStandalone.CSharp.csproj", "{A092FA91-856B-4ACA-B1C2-10BDBA366185}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorHosted", "src\Microsoft.AspNetCore.Blazor.Templates\content\BlazorHosted.CSharp\BlazorHosted\BlazorHosted.csproj", "{3EECBE6C-AD8A-4AE4-855E-B62D46F9755A}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BlazorHosted.CSharp", "BlazorHosted.CSharp", "{73DA1DFD-79F0-4BA2-B0B6-4F3A21D2C3F8}"
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorHosted.Server", "src\Microsoft.AspNetCore.Blazor.Templates\content\BlazorHosted.CSharp\BlazorHosted.Server\BlazorHosted.Server.csproj", "{3C841633-DF1D-4C39-AADF-3B584E2D3D03}"
|
|
||||||
EndProject
|
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HostedInAspNet", "HostedInAspNet", "{73DA1DFD-79F0-4BA2-B0B6-4F3A21D2C3F8}"
|
|
||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
src\Microsoft.AspNetCore.Blazor.Templates\content\BlazorHosted.CSharp\NuGet.config = src\Microsoft.AspNetCore.Blazor.Templates\content\BlazorHosted.CSharp\NuGet.config
|
src\Microsoft.AspNetCore.Blazor.Templates\content\BlazorHosted.CSharp\NuGet.config = src\Microsoft.AspNetCore.Blazor.Templates\content\BlazorHosted.CSharp\NuGet.config
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorHosted.CSharp.Client", "src\Microsoft.AspNetCore.Blazor.Templates\content\BlazorHosted.CSharp\BlazorHosted.CSharp.Client\BlazorHosted.CSharp.Client.csproj", "{7549444A-9C81-44DE-AD0D-2C55501EAAC7}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorHosted.CSharp.Server", "src\Microsoft.AspNetCore.Blazor.Templates\content\BlazorHosted.CSharp\BlazorHosted.CSharp.Server\BlazorHosted.CSharp.Server.csproj", "{78ED9932-0912-4F36-8F82-33DE850E7A33}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorHosted.CSharp.Shared", "src\Microsoft.AspNetCore.Blazor.Templates\content\BlazorHosted.CSharp\BlazorHosted.CSharp.Shared\BlazorHosted.CSharp.Shared.csproj", "{F3E02B21-1127-431A-B832-0E53CB72097B}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
|
@ -195,14 +197,18 @@ Global
|
||||||
{A092FA91-856B-4ACA-B1C2-10BDBA366185}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{A092FA91-856B-4ACA-B1C2-10BDBA366185}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{A092FA91-856B-4ACA-B1C2-10BDBA366185}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{A092FA91-856B-4ACA-B1C2-10BDBA366185}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{A092FA91-856B-4ACA-B1C2-10BDBA366185}.Release|Any CPU.Build.0 = Release|Any CPU
|
{A092FA91-856B-4ACA-B1C2-10BDBA366185}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{3EECBE6C-AD8A-4AE4-855E-B62D46F9755A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{7549444A-9C81-44DE-AD0D-2C55501EAAC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{3EECBE6C-AD8A-4AE4-855E-B62D46F9755A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{7549444A-9C81-44DE-AD0D-2C55501EAAC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{3EECBE6C-AD8A-4AE4-855E-B62D46F9755A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{7549444A-9C81-44DE-AD0D-2C55501EAAC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{3EECBE6C-AD8A-4AE4-855E-B62D46F9755A}.Release|Any CPU.Build.0 = Release|Any CPU
|
{7549444A-9C81-44DE-AD0D-2C55501EAAC7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{3C841633-DF1D-4C39-AADF-3B584E2D3D03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{78ED9932-0912-4F36-8F82-33DE850E7A33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{3C841633-DF1D-4C39-AADF-3B584E2D3D03}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{78ED9932-0912-4F36-8F82-33DE850E7A33}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{3C841633-DF1D-4C39-AADF-3B584E2D3D03}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{78ED9932-0912-4F36-8F82-33DE850E7A33}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{3C841633-DF1D-4C39-AADF-3B584E2D3D03}.Release|Any CPU.Build.0 = Release|Any CPU
|
{78ED9932-0912-4F36-8F82-33DE850E7A33}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F3E02B21-1127-431A-B832-0E53CB72097B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F3E02B21-1127-431A-B832-0E53CB72097B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F3E02B21-1127-431A-B832-0E53CB72097B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F3E02B21-1127-431A-B832-0E53CB72097B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
@ -239,9 +245,10 @@ Global
|
||||||
{AF79BB84-BAE6-4F9A-9AD5-B0E3D7455288} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
|
{AF79BB84-BAE6-4F9A-9AD5-B0E3D7455288} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
|
||||||
{8C160273-0A1D-4D79-9F7B-7687B2D2F7C4} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
|
{8C160273-0A1D-4D79-9F7B-7687B2D2F7C4} = {B867E038-B3CE-43E3-9292-61568C46CDEB}
|
||||||
{A092FA91-856B-4ACA-B1C2-10BDBA366185} = {E8EBA72C-D555-43AE-BC98-F0B2D05F6A07}
|
{A092FA91-856B-4ACA-B1C2-10BDBA366185} = {E8EBA72C-D555-43AE-BC98-F0B2D05F6A07}
|
||||||
{3EECBE6C-AD8A-4AE4-855E-B62D46F9755A} = {73DA1DFD-79F0-4BA2-B0B6-4F3A21D2C3F8}
|
|
||||||
{3C841633-DF1D-4C39-AADF-3B584E2D3D03} = {73DA1DFD-79F0-4BA2-B0B6-4F3A21D2C3F8}
|
|
||||||
{73DA1DFD-79F0-4BA2-B0B6-4F3A21D2C3F8} = {E8EBA72C-D555-43AE-BC98-F0B2D05F6A07}
|
{73DA1DFD-79F0-4BA2-B0B6-4F3A21D2C3F8} = {E8EBA72C-D555-43AE-BC98-F0B2D05F6A07}
|
||||||
|
{7549444A-9C81-44DE-AD0D-2C55501EAAC7} = {73DA1DFD-79F0-4BA2-B0B6-4F3A21D2C3F8}
|
||||||
|
{78ED9932-0912-4F36-8F82-33DE850E7A33} = {73DA1DFD-79F0-4BA2-B0B6-4F3A21D2C3F8}
|
||||||
|
{F3E02B21-1127-431A-B832-0E53CB72097B} = {73DA1DFD-79F0-4BA2-B0B6-4F3A21D2C3F8}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {504DA352-6788-4DC0-8705-82167E72A4D3}
|
SolutionGuid = {504DA352-6788-4DC0-8705-82167E72A4D3}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.1" />
|
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,13 @@
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.ResponseCompression;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Mime;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Blazor.Cli.Server
|
namespace Microsoft.AspNetCore.Blazor.Cli.Server
|
||||||
{
|
{
|
||||||
|
|
@ -16,11 +19,17 @@ namespace Microsoft.AspNetCore.Blazor.Cli.Server
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
services.AddRouting();
|
services.AddRouting();
|
||||||
|
services.AddResponseCompression(options =>
|
||||||
|
{
|
||||||
|
options.MimeTypes = ResponseCompressionDefaults.MimeTypes
|
||||||
|
.Concat(new[] { MediaTypeNames.Application.Octet });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app, IConfiguration configuration)
|
public void Configure(IApplicationBuilder app, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
|
app.UseResponseCompression();
|
||||||
EnableConfiguredPathbase(app, configuration);
|
EnableConfiguredPathbase(app, configuration);
|
||||||
|
|
||||||
var clientAssemblyPath = FindClientAssemblyPath(app);
|
var clientAssemblyPath = FindClientAssemblyPath(app);
|
||||||
|
|
|
||||||
|
|
@ -9,18 +9,19 @@
|
||||||
"guids": [
|
"guids": [
|
||||||
"4C26868E-5E7C-458D-82E3-040509D0C71F",
|
"4C26868E-5E7C-458D-82E3-040509D0C71F",
|
||||||
"5990939C-7E7B-4CFA-86FF-44CA5756498A",
|
"5990939C-7E7B-4CFA-86FF-44CA5756498A",
|
||||||
"650B3CE7-2E93-4CC4-9F46-466686815EAA"
|
"650B3CE7-2E93-4CC4-9F46-466686815EAA",
|
||||||
|
"0AFFA7FD-4E37-4636-AB91-3753E746DB98"
|
||||||
],
|
],
|
||||||
"identity": "Microsoft.Web.Blazor.Hosted.CSharp",
|
"identity": "Microsoft.Web.Blazor.Hosted.CSharp",
|
||||||
"name": "Blazor (hosted in ASP.NET server)",
|
"name": "Blazor (hosted in ASP.NET server)",
|
||||||
"preferNameDirectory": true,
|
"preferNameDirectory": true,
|
||||||
"primaryOutputs": [
|
"primaryOutputs": [
|
||||||
{
|
{
|
||||||
"path": "BlazorHosted.sln"
|
"path": "BlazorHosted.CSharp.sln"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"shortName": "blazorhosted",
|
"shortName": "blazorhosted",
|
||||||
"sourceName": "BlazorHosted",
|
"sourceName": "BlazorHosted.CSharp",
|
||||||
"sources": [
|
"sources": [
|
||||||
{
|
{
|
||||||
"source": "./",
|
"source": "./",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
<!--
|
||||||
|
Configuring this stuff here is temporary. Later we'll move the app config
|
||||||
|
into Program.cs, and it won't be necessary to specify AppAssembly.
|
||||||
|
-->
|
||||||
|
<c:Router AppAssembly=@(typeof(Program).Assembly)
|
||||||
|
PagesNamespace=@("BlazorHosted.CSharp.Client.Pages") />
|
||||||
|
|
@ -1,13 +1,16 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.0.5-preview1-10031" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.0.5-preview1-10038" PrivateAssets="all" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.0.5-preview1-10031" />
|
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.0.5-preview1-10038" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\BlazorHosted.CSharp.Shared\BlazorHosted.CSharp.Shared.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
@using Microsoft.AspNetCore.Blazor
|
@using Microsoft.AspNetCore.Blazor.Browser.Services.Temporary
|
||||||
@using Microsoft.AspNetCore.Blazor.Browser.Services.Temporary
|
@using BlazorHosted.CSharp.Shared
|
||||||
@inject HttpClient Http
|
@inject HttpClient Http
|
||||||
|
|
||||||
<h1>Weather forecast</h1>
|
<h1>Weather forecast</h1>
|
||||||
|
|
@ -25,7 +25,7 @@ else
|
||||||
@foreach (var forecast in forecasts)
|
@foreach (var forecast in forecasts)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>@forecast.DateFormatted</td>
|
<td>@forecast.Date.ToShortDateString()</td>
|
||||||
<td>@forecast.TemperatureC</td>
|
<td>@forecast.TemperatureC</td>
|
||||||
<td>@forecast.TemperatureF</td>
|
<td>@forecast.TemperatureF</td>
|
||||||
<td>@forecast.Summary</td>
|
<td>@forecast.Summary</td>
|
||||||
|
|
@ -40,15 +40,7 @@ else
|
||||||
|
|
||||||
protected override async Task OnInitAsync()
|
protected override async Task OnInitAsync()
|
||||||
{
|
{
|
||||||
var json = await Http.GetStringAsync("/sample-data/weather.json");
|
var json = await Http.GetStringAsync("/api/SampleData/WeatherForecasts");
|
||||||
forecasts = JsonUtil.Deserialize<WeatherForecast[]>(json);
|
forecasts = JsonUtil.Deserialize<WeatherForecast[]>(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
class WeatherForecast
|
|
||||||
{
|
|
||||||
public string DateFormatted { get; set; }
|
|
||||||
public int TemperatureC { get; set; }
|
|
||||||
public int TemperatureF { get; set; }
|
|
||||||
public string Summary { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
@(Layout<MainLayout>())
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
using Microsoft.AspNetCore.Blazor.Browser.Services;
|
using Microsoft.AspNetCore.Blazor.Browser.Services;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace BlazorHosted
|
namespace BlazorHosted.CSharp.Client
|
||||||
{
|
{
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
@using Microsoft.AspNetCore.Blazor.RenderTree
|
@(Implements<ILayoutComponent>())
|
||||||
@(Implements<Microsoft.AspNetCore.Blazor.Layouts.ILayoutComponent>())
|
|
||||||
|
|
||||||
<div class='container-fluid'>
|
<div class='container-fluid'>
|
||||||
<div class='row'>
|
<div class='row'>
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
@using Microsoft.AspNetCore.Blazor.Routing
|
<div class='main-nav'>
|
||||||
<div class='main-nav'>
|
|
||||||
<div class='navbar navbar-inverse'>
|
<div class='navbar navbar-inverse'>
|
||||||
<div class='navbar-header'>
|
<div class='navbar-header'>
|
||||||
<button type='button' class='navbar-toggle' data-toggle='collapse' data-target='.navbar-collapse'>
|
<button type='button' class='navbar-toggle' data-toggle='collapse' data-target='.navbar-collapse'>
|
||||||
|
|
@ -8,7 +7,7 @@
|
||||||
<span class='icon-bar'></span>
|
<span class='icon-bar'></span>
|
||||||
<span class='icon-bar'></span>
|
<span class='icon-bar'></span>
|
||||||
</button>
|
</button>
|
||||||
<a class='navbar-brand' href='/'>BlazorHosted</a>
|
<a class='navbar-brand' href='/'>BlazorHosted.CSharp</a>
|
||||||
</div>
|
</div>
|
||||||
<div class='clearfix'></div>
|
<div class='clearfix'></div>
|
||||||
<div class='navbar-collapse collapse'>
|
<div class='navbar-collapse collapse'>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
@using Microsoft.AspNetCore.Blazor
|
||||||
|
@using Microsoft.AspNetCore.Blazor.Layouts
|
||||||
|
@using Microsoft.AspNetCore.Blazor.Routing
|
||||||
|
@using BlazorHosted.CSharp.Client
|
||||||
|
@using BlazorHosted.CSharp.Client.Shared
|
||||||
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 106 KiB |
|
|
@ -2,7 +2,7 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title>BlazorHosted</title>
|
<title>BlazorHosted.CSharp</title>
|
||||||
<base href="/" />
|
<base href="/" />
|
||||||
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
|
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
|
||||||
<link href="css/site.css" rel="stylesheet" />
|
<link href="css/site.css" rel="stylesheet" />
|
||||||
|
|
@ -6,11 +6,12 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Blazor.Server" Version="0.0.5-preview1-10031" />
|
<PackageReference Include="Microsoft.AspNetCore.Blazor.Server" Version="0.0.5-preview1-10038" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\BlazorHosted\BlazorHosted.csproj" />
|
<ProjectReference Include="..\BlazorHosted.CSharp.Client\BlazorHosted.CSharp.Client.csproj" />
|
||||||
|
<ProjectReference Include="..\BlazorHosted.CSharp.Shared\BlazorHosted.CSharp.Shared.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
using BlazorHosted.CSharp.Shared;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BlazorHosted.CSharp.Server.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class SampleDataController : Controller
|
||||||
|
{
|
||||||
|
private static string[] Summaries = new[]
|
||||||
|
{
|
||||||
|
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||||
|
};
|
||||||
|
|
||||||
|
[HttpGet("[action]")]
|
||||||
|
public IEnumerable<WeatherForecast> WeatherForecasts()
|
||||||
|
{
|
||||||
|
var rng = new Random();
|
||||||
|
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||||
|
{
|
||||||
|
Date = DateTime.Now.AddDays(index),
|
||||||
|
TemperatureC = rng.Next(-20, 55),
|
||||||
|
Summary = Summaries[rng.Next(Summaries.Length)]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,7 @@ using Microsoft.AspNetCore;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
namespace BlazorHosted.Server
|
namespace BlazorHosted.CSharp.Server
|
||||||
{
|
{
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
|
|
@ -3,9 +3,13 @@
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.ResponseCompression;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Newtonsoft.Json.Serialization;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Mime;
|
||||||
|
|
||||||
namespace BlazorHosted.Server
|
namespace BlazorHosted.CSharp.Server
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
|
|
@ -13,17 +17,34 @@ namespace BlazorHosted.Server
|
||||||
// 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.AddMvc().AddJsonOptions(options =>
|
||||||
|
{
|
||||||
|
options.SerializerSettings.ContractResolver = new DefaultContractResolver();
|
||||||
|
});
|
||||||
|
|
||||||
|
services.AddResponseCompression(options =>
|
||||||
|
{
|
||||||
|
options.MimeTypes = ResponseCompressionDefaults.MimeTypes
|
||||||
|
.Concat(new[] { MediaTypeNames.Application.Octet });
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
||||||
{
|
{
|
||||||
|
app.UseResponseCompression();
|
||||||
|
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseBlazor<BlazorHosted.Program>();
|
app.UseMvc(routes =>
|
||||||
|
{
|
||||||
|
routes.MapRoute(name: "default", template: "{controller}/{action}/{id?}");
|
||||||
|
});
|
||||||
|
|
||||||
|
app.UseBlazor<Client.Program>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace BlazorHosted.CSharp.Shared
|
||||||
|
{
|
||||||
|
public class WeatherForecast
|
||||||
|
{
|
||||||
|
public DateTime Date { get; set; }
|
||||||
|
public int TemperatureC { get; set; }
|
||||||
|
public string Summary { get; set; }
|
||||||
|
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,9 +2,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 15
|
# Visual Studio 15
|
||||||
VisualStudioVersion = 15.0.27130.2027
|
VisualStudioVersion = 15.0.27130.2027
|
||||||
MinimumVisualStudioVersion = 15.0.26124.0
|
MinimumVisualStudioVersion = 15.0.26124.0
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorHosted", "BlazorHosted\BlazorHosted.csproj", "{5990939C-7E7B-4CFA-86FF-44CA5756498A}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorHosted.CSharp.Server", "BlazorHosted.CSharp.Server\BlazorHosted.CSharp.Server.csproj", "{650B3CE7-2E93-4CC4-9F46-466686815EAA}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorHosted.Server", "BlazorHosted.Server\BlazorHosted.Server.csproj", "{650B3CE7-2E93-4CC4-9F46-466686815EAA}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorHosted.CSharp.Client", "BlazorHosted.CSharp.Client\BlazorHosted.CSharp.Client.csproj", "{5990939C-7E7B-4CFA-86FF-44CA5756498A}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorHosted.CSharp.Shared", "BlazorHosted.CSharp.Shared\BlazorHosted.CSharp.Shared.csproj", "{0AFFA7FD-4E37-4636-AB91-3753E746DB98}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
|
@ -40,6 +42,18 @@ Global
|
||||||
{650B3CE7-2E93-4CC4-9F46-466686815EAA}.Release|x64.Build.0 = Release|Any CPU
|
{650B3CE7-2E93-4CC4-9F46-466686815EAA}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{650B3CE7-2E93-4CC4-9F46-466686815EAA}.Release|x86.ActiveCfg = Release|Any CPU
|
{650B3CE7-2E93-4CC4-9F46-466686815EAA}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{650B3CE7-2E93-4CC4-9F46-466686815EAA}.Release|x86.Build.0 = Release|Any CPU
|
{650B3CE7-2E93-4CC4-9F46-466686815EAA}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{0AFFA7FD-4E37-4636-AB91-3753E746DB98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{0AFFA7FD-4E37-4636-AB91-3753E746DB98}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{0AFFA7FD-4E37-4636-AB91-3753E746DB98}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{0AFFA7FD-4E37-4636-AB91-3753E746DB98}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{0AFFA7FD-4E37-4636-AB91-3753E746DB98}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{0AFFA7FD-4E37-4636-AB91-3753E746DB98}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{0AFFA7FD-4E37-4636-AB91-3753E746DB98}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{0AFFA7FD-4E37-4636-AB91-3753E746DB98}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{0AFFA7FD-4E37-4636-AB91-3753E746DB98}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{0AFFA7FD-4E37-4636-AB91-3753E746DB98}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{0AFFA7FD-4E37-4636-AB91-3753E746DB98}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{0AFFA7FD-4E37-4636-AB91-3753E746DB98}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
@using Microsoft.AspNetCore.Blazor.Routing
|
|
||||||
<!--
|
|
||||||
Configuring this stuff here is temporary. Later we'll move the app config
|
|
||||||
into Program.cs, and it won't be necessary to specify AppAssembly.
|
|
||||||
-->
|
|
||||||
<c:Router AppAssembly=@(typeof(BlazorHosted.Program).Assembly)
|
|
||||||
PagesNamespace=@("BlazorHosted.Pages") />
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
@(Layout<BlazorHosted.Shared.MainLayout>())
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"DateFormatted": "06/05/2018",
|
|
||||||
"TemperatureC": 1,
|
|
||||||
"Summary": "Freezing",
|
|
||||||
"TemperatureF": 33
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"DateFormatted": "07/05/2018",
|
|
||||||
"TemperatureC": 14,
|
|
||||||
"Summary": "Bracing",
|
|
||||||
"TemperatureF": 57
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"DateFormatted": "08/05/2018",
|
|
||||||
"TemperatureC": -13,
|
|
||||||
"Summary": "Freezing",
|
|
||||||
"TemperatureF": 9
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"DateFormatted": "09/05/2018",
|
|
||||||
"TemperatureC": -16,
|
|
||||||
"Summary": "Balmy",
|
|
||||||
"TemperatureF": 4
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"DateFormatted": "10/05/2018",
|
|
||||||
"TemperatureC": -2,
|
|
||||||
"Summary": "Chilly",
|
|
||||||
"TemperatureF": 29
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
@using Microsoft.AspNetCore.Blazor.Routing
|
<!--
|
||||||
<!--
|
|
||||||
Configuring this stuff here is temporary. Later we'll move the app config
|
Configuring this stuff here is temporary. Later we'll move the app config
|
||||||
into Program.cs, and it won't be necessary to specify AppAssembly.
|
into Program.cs, and it won't be necessary to specify AppAssembly.
|
||||||
-->
|
-->
|
||||||
<c:Router AppAssembly=@(typeof(BlazorStandalone.CSharp.Program).Assembly)
|
<c:Router AppAssembly=@(typeof(Program).Assembly)
|
||||||
PagesNamespace=@("BlazorStandalone.CSharp.Pages") />
|
PagesNamespace=@("BlazorStandalone.CSharp.Pages") />
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,15 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<RunCommand>dotnet</RunCommand>
|
<RunCommand>dotnet</RunCommand>
|
||||||
<RunArguments>blazor serve</RunArguments>
|
<RunArguments>blazor serve</RunArguments>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.0.5-preview1-10031" PrivateAssets="all" />
|
<PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.0.5-preview1-10038" PrivateAssets="all" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.0.5-preview1-10031" />
|
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.0.5-preview1-10038" />
|
||||||
<DotNetCliToolReference Include="Microsoft.AspNetCore.Blazor.Cli" Version="0.0.5-preview1-10031" />
|
<DotNetCliToolReference Include="Microsoft.AspNetCore.Blazor.Cli" Version="0.0.5-preview1-10038" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
@using Microsoft.AspNetCore.Blazor
|
@using Microsoft.AspNetCore.Blazor.Browser.Services.Temporary
|
||||||
@using Microsoft.AspNetCore.Blazor.Browser.Services.Temporary
|
|
||||||
@inject HttpClient Http
|
@inject HttpClient Http
|
||||||
|
|
||||||
<h1>Weather forecast</h1>
|
<h1>Weather forecast</h1>
|
||||||
|
|
@ -25,7 +24,7 @@ else
|
||||||
@foreach (var forecast in forecasts)
|
@foreach (var forecast in forecasts)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>@forecast.DateFormatted</td>
|
<td>@forecast.Date.ToShortDateString()</td>
|
||||||
<td>@forecast.TemperatureC</td>
|
<td>@forecast.TemperatureC</td>
|
||||||
<td>@forecast.TemperatureF</td>
|
<td>@forecast.TemperatureF</td>
|
||||||
<td>@forecast.Summary</td>
|
<td>@forecast.Summary</td>
|
||||||
|
|
@ -46,7 +45,7 @@ else
|
||||||
|
|
||||||
class WeatherForecast
|
class WeatherForecast
|
||||||
{
|
{
|
||||||
public string DateFormatted { get; set; }
|
public DateTime Date { get; set; }
|
||||||
public int TemperatureC { get; set; }
|
public int TemperatureC { get; set; }
|
||||||
public int TemperatureF { get; set; }
|
public int TemperatureF { get; set; }
|
||||||
public string Summary { get; set; }
|
public string Summary { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
@(Layout<BlazorStandalone.CSharp.Shared.MainLayout>())
|
@(Layout<MainLayout>())
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
@using Microsoft.AspNetCore.Blazor.RenderTree
|
@(Implements<ILayoutComponent>())
|
||||||
@(Implements<Microsoft.AspNetCore.Blazor.Layouts.ILayoutComponent>())
|
|
||||||
|
|
||||||
<div class='container-fluid'>
|
<div class='container-fluid'>
|
||||||
<div class='row'>
|
<div class='row'>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
@using Microsoft.AspNetCore.Blazor.Routing
|
<div class='main-nav'>
|
||||||
<div class='main-nav'>
|
|
||||||
<div class='navbar navbar-inverse'>
|
<div class='navbar navbar-inverse'>
|
||||||
<div class='navbar-header'>
|
<div class='navbar-header'>
|
||||||
<button type='button' class='navbar-toggle' data-toggle='collapse' data-target='.navbar-collapse'>
|
<button type='button' class='navbar-toggle' data-toggle='collapse' data-target='.navbar-collapse'>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
@using Microsoft.AspNetCore.Blazor
|
||||||
|
@using Microsoft.AspNetCore.Blazor.Layouts
|
||||||
|
@using Microsoft.AspNetCore.Blazor.Routing
|
||||||
|
@using BlazorStandalone.CSharp
|
||||||
|
@using BlazorStandalone.CSharp.Shared
|
||||||
|
|
@ -1,30 +1,30 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"DateFormatted": "06/05/2018",
|
"Date": "2018-05-06",
|
||||||
"TemperatureC": 1,
|
"TemperatureC": 1,
|
||||||
"Summary": "Freezing",
|
"Summary": "Freezing",
|
||||||
"TemperatureF": 33
|
"TemperatureF": 33
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"DateFormatted": "07/05/2018",
|
"Date": "2018-05-07",
|
||||||
"TemperatureC": 14,
|
"TemperatureC": 14,
|
||||||
"Summary": "Bracing",
|
"Summary": "Bracing",
|
||||||
"TemperatureF": 57
|
"TemperatureF": 57
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"DateFormatted": "08/05/2018",
|
"Date": "2018-05-08",
|
||||||
"TemperatureC": -13,
|
"TemperatureC": -13,
|
||||||
"Summary": "Freezing",
|
"Summary": "Freezing",
|
||||||
"TemperatureF": 9
|
"TemperatureF": 9
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"DateFormatted": "09/05/2018",
|
"Date": "2018-05-09",
|
||||||
"TemperatureC": -16,
|
"TemperatureC": -16,
|
||||||
"Summary": "Balmy",
|
"Summary": "Balmy",
|
||||||
"TemperatureF": 4
|
"TemperatureF": 4
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"DateFormatted": "10/05/2018",
|
"Date": "2018-05-10",
|
||||||
"TemperatureC": -2,
|
"TemperatureC": -2,
|
||||||
"Summary": "Chilly",
|
"Summary": "Chilly",
|
||||||
"TemperatureF": 29
|
"TemperatureF": 29
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue