Skip to content

Commit 93fe5b1

Browse files
Update tutorial to .NET Core 3
1 parent d555ff8 commit 93fe5b1

File tree

3 files changed

+39
-46
lines changed

3 files changed

+39
-46
lines changed

tutorial-code/Startup.cs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace ReactDemo
1818
{
1919
public class Startup
2020
{
21-
public Startup(IHostingEnvironment env)
21+
public Startup(IWebHostEnvironment env)
2222
{
2323
var builder = new ConfigurationBuilder()
2424
.SetBasePath(env.ContentRootPath)
@@ -43,20 +43,9 @@ public void ConfigureServices(IServiceCollection services)
4343
}
4444

4545
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
46-
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
46+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
4747
{
48-
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
49-
loggerFactory.AddDebug();
50-
51-
if (env.IsDevelopment())
52-
{
53-
app.UseDeveloperExceptionPage();
54-
app.UseBrowserLink();
55-
}
56-
else
57-
{
58-
app.UseExceptionHandler("/Home/Error");
59-
}
48+
app.UseDeveloperExceptionPage();
6049

6150
// Initialise ReactJS.NET. Must be before static files.
6251
app.UseReact(config =>
@@ -85,11 +74,11 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
8574

8675
app.UseStaticFiles();
8776

88-
app.UseMvc(routes =>
77+
app.UseRouting();
78+
79+
app.UseEndpoints(endpoints =>
8980
{
90-
routes.MapRoute(
91-
name: "default",
92-
template: "{controller=Home}/{action=Index}/{id?}");
81+
endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
9382
});
9483
}
9584
}

tutorial-code/tutorial-code.csproj

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
2-
<PropertyGroup>
3-
<TargetFramework>netcoreapp2.1</TargetFramework>
4-
<PreserveCompilationContext>true</PreserveCompilationContext>
5-
<AssemblyName>tutorial-code</AssemblyName>
6-
<OutputType>Exe</OutputType>
7-
<PackageId>tutorial-code</PackageId>
8-
</PropertyGroup>
9-
<ItemGroup>
10-
<None Include="App.config" />
11-
<None Update="wwwroot\**\*;Views\**\*;Areas\**\Views">
12-
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
13-
</None>
14-
</ItemGroup>
15-
<ItemGroup>
16-
<PackageReference Include="JavascriptEngineSwitcher.ChakraCore" Version="3.1.1" />
2+
<PropertyGroup>
3+
<TargetFramework>netcoreapp3.0</TargetFramework>
4+
<PreserveCompilationContext>true</PreserveCompilationContext>
5+
<AssemblyName>tutorial-code</AssemblyName>
6+
<OutputType>Exe</OutputType>
7+
<PackageId>tutorial-code</PackageId>
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<None Include="App.config" />
11+
<None Update="wwwroot\**\*;Views\**\*;Areas\**\Views">
12+
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
13+
</None>
14+
</ItemGroup>
15+
<ItemGroup>
16+
<PackageReference Include="JavascriptEngineSwitcher.ChakraCore" Version="3.1.1" />
1717
<PackageReference Include="JavascriptEngineSwitcher.ChakraCore.native.linux-x64" Version="3.1.1" />
1818
<PackageReference Include="JavascriptEngineSwitcher.ChakraCore.native.osx-x64" Version="3.1.1" />
1919
<PackageReference Include="JavascriptEngineSwitcher.ChakraCore.native.win-x64" Version="3.1.1" />
2020
<PackageReference Include="JavascriptEngineSwitcher.Extensions.MsDependencyInjection" Version="3.1.0" />
21-
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
22-
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
23-
<PackageReference Include="Microsoft.NET.Sdk.Razor" Version="2.2.0" />
24-
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
25-
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
26-
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
27-
<PackageReference Include="React.AspNet" Version="4.1.1" />
28-
</ItemGroup>
21+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
22+
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
23+
<PackageReference Include="React.AspNet" Version="5.0.0-alpha3" />
24+
</ItemGroup>
25+
<ItemGroup>
26+
<Content Update="Views\Home\Index.cshtml">
27+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
28+
</Content>
29+
</ItemGroup>
2930
</Project>

tutorial-code/web.config

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3-
43
<!--
54
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
65
-->
7-
86
<system.webServer>
97
<handlers>
10-
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
8+
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
119
</handlers>
12-
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
10+
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" hostingModel="InProcess">
11+
<environmentVariables>
12+
<environmentVariable name="COMPLUS_ForceENC" value="1" />
13+
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
14+
</environmentVariables>
15+
</aspNetCore>
1316
</system.webServer>
14-
</configuration>
17+
</configuration>

0 commit comments

Comments
 (0)