Skip to content

Commit b75bac9

Browse files
committed
Ported WebStartup sample (#326)
1 parent 96474bb commit b75bac9

File tree

6 files changed

+14
-29
lines changed

6 files changed

+14
-29
lines changed

samples/NoStartup/NoStartup.Components/NoStartup.Components.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
<TargetFramework>netcoreapp3.0</TargetFramework>
55
<NoWarn>$(NoWarn);CS1591</NoWarn>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
7-
<AssemblyName>NoStartup.Components</AssemblyName>
8-
<PackageId>NoStartup.Components</PackageId>
9-
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
10-
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
11-
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
127
</PropertyGroup>
138

149
<ItemGroup>

samples/NoStartup/NoStartup.Services/NoStartup.Services.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
<TargetFramework>netstandard2.0</TargetFramework>
55
<NoWarn>$(NoWarn);CS1591</NoWarn>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
7-
<AssemblyName>NoStartup.Services</AssemblyName>
8-
<PackageId>NoStartup.Services</PackageId>
9-
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
10-
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
11-
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
127
</PropertyGroup>
138

149
</Project>

samples/NoStartup/NoStartup.Test/NoStartup.Test.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<PropertyGroup>
44
<TargetFramework>netcoreapp3.0</TargetFramework>
55
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
6-
<PreserveCompilationContext>true</PreserveCompilationContext>
76
</PropertyGroup>
87

98
<ItemGroup>

samples/WebStartup/WebStartup.Test/WebStartup.Test.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.2</TargetFramework>
4+
<TargetFramework>netcoreapp3.0</TargetFramework>
55
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.AspNetCore.App" />
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
9+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0-*" />
1110
<PackageReference Include="xunit" Version="2.4.1" />
1211
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
1312
<PrivateAssets>all</PrivateAssets>

samples/WebStartup/WebStartup.Web/Startup.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Microsoft.AspNetCore.Mvc;
77
using Microsoft.Extensions.Configuration;
88
using Microsoft.Extensions.DependencyInjection;
9+
using Microsoft.Extensions.Hosting;
910

1011
public class Startup
1112
{
@@ -24,11 +25,11 @@ public void ConfigureServices(IServiceCollection services)
2425
options.MinimumSameSitePolicy = SameSiteMode.None;
2526
});
2627

27-
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
28+
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
2829
}
2930

3031
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
31-
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
32+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
3233
{
3334
if (env.IsDevelopment())
3435
{
@@ -45,16 +46,18 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
4546
app.UseStaticFiles();
4647
app.UseCookiePolicy();
4748

48-
app.UseMvc(routes =>
49+
app.UseRouting();
50+
51+
app.UseEndpoints(routes =>
4952
{
50-
routes.MapRoute(
53+
routes.MapControllerRoute(
5154
name: "custom",
52-
template: "Index",
55+
pattern: "Index",
5356
defaults: new { controller = "Home", action = "Index" });
5457

55-
routes.MapRoute(
58+
routes.MapControllerRoute(
5659
name: "default",
57-
template: "{controller=Home}/{action=Index}/{id?}");
60+
pattern: "{controller=Home}/{action=Index}/{id?}");
5861
});
5962
}
6063
}
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.2</TargetFramework>
4+
<TargetFramework>netcoreapp3.0</TargetFramework>
55
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
77
</PropertyGroup>
88

9-
10-
<ItemGroup>
11-
<PackageReference Include="Microsoft.AspNetCore.App" />
12-
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
13-
</ItemGroup>
14-
159
</Project>

0 commit comments

Comments
 (0)