Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions Microsoft.AspNetCore.SystemWebAdapters.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvcApp", "samples\MvcApp\MvcApp.csproj", "{174A36F1-27ED-43FC-A3A1-00DA58C4E30C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MvcCoreApp", "samples\MvcCoreApp\MvcCoreApp.csproj", "{B1D06F62-B315-4ED8-8109-168B4D4E4B86}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F9DB9323-C919-49E8-8F96-B923D2F42E60}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{A1BDA50C-D70B-416C-97F1-74B0649797C5}"
Expand Down Expand Up @@ -61,6 +57,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Samples.RemoteAuth.Forms.Te
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SystemWebAdapters.Abstractions", "src\Microsoft.AspNetCore.SystemWebAdapters.Abstractions\Microsoft.AspNetCore.SystemWebAdapters.Abstractions.csproj", "{632E6195-4304-4C67-AABB-7CFC3F9086B6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Identity", "Identity", "{9C8EBDB5-FA17-4C9C-8946-04692AC752CE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvcApp", "samples\RemoteAuth\Identity\MvcApp\MvcApp.csproj", "{174A36F1-27ED-43FC-A3A1-00DA58C4E30C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MvcCoreApp", "samples\RemoteAuth\Identity\MvcCoreApp\MvcCoreApp.csproj", "{2BF8EE74-1AB3-4DB8-ADDE-27A35981CA04}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoreApp", "samples\CoreApp\CoreApp.csproj", "{431651D7-D40A-403E-813C-496A1414AA22}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -79,14 +83,6 @@ Global
{11DD4D64-7A95-4635-A273-775715E18852}.Debug|Any CPU.Build.0 = Debug|Any CPU
{11DD4D64-7A95-4635-A273-775715E18852}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11DD4D64-7A95-4635-A273-775715E18852}.Release|Any CPU.Build.0 = Release|Any CPU
{174A36F1-27ED-43FC-A3A1-00DA58C4E30C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{174A36F1-27ED-43FC-A3A1-00DA58C4E30C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{174A36F1-27ED-43FC-A3A1-00DA58C4E30C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{174A36F1-27ED-43FC-A3A1-00DA58C4E30C}.Release|Any CPU.Build.0 = Release|Any CPU
{B1D06F62-B315-4ED8-8109-168B4D4E4B86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B1D06F62-B315-4ED8-8109-168B4D4E4B86}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1D06F62-B315-4ED8-8109-168B4D4E4B86}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1D06F62-B315-4ED8-8109-168B4D4E4B86}.Release|Any CPU.Build.0 = Release|Any CPU
{898C9B2C-E43A-434F-9927-F6697C0ACE40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{898C9B2C-E43A-434F-9927-F6697C0ACE40}.Debug|Any CPU.Build.0 = Debug|Any CPU
{898C9B2C-E43A-434F-9927-F6697C0ACE40}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -139,6 +135,18 @@ Global
{632E6195-4304-4C67-AABB-7CFC3F9086B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{632E6195-4304-4C67-AABB-7CFC3F9086B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{632E6195-4304-4C67-AABB-7CFC3F9086B6}.Release|Any CPU.Build.0 = Release|Any CPU
{174A36F1-27ED-43FC-A3A1-00DA58C4E30C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{174A36F1-27ED-43FC-A3A1-00DA58C4E30C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{174A36F1-27ED-43FC-A3A1-00DA58C4E30C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{174A36F1-27ED-43FC-A3A1-00DA58C4E30C}.Release|Any CPU.Build.0 = Release|Any CPU
{2BF8EE74-1AB3-4DB8-ADDE-27A35981CA04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2BF8EE74-1AB3-4DB8-ADDE-27A35981CA04}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2BF8EE74-1AB3-4DB8-ADDE-27A35981CA04}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2BF8EE74-1AB3-4DB8-ADDE-27A35981CA04}.Release|Any CPU.Build.0 = Release|Any CPU
{431651D7-D40A-403E-813C-496A1414AA22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{431651D7-D40A-403E-813C-496A1414AA22}.Debug|Any CPU.Build.0 = Debug|Any CPU
{431651D7-D40A-403E-813C-496A1414AA22}.Release|Any CPU.ActiveCfg = Release|Any CPU
{431651D7-D40A-403E-813C-496A1414AA22}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -147,8 +155,6 @@ Global
{55C1BBE0-B922-46B0-8F2C-8472BC9A5F33} = {F9DB9323-C919-49E8-8F96-B923D2F42E60}
{DA28CCAB-3C88-46F1-B779-43C573ED49E5} = {A1BDA50C-D70B-416C-97F1-74B0649797C5}
{11DD4D64-7A95-4635-A273-775715E18852} = {95915611-30BF-4AFF-AE41-5CDC6F57DCF7}
{174A36F1-27ED-43FC-A3A1-00DA58C4E30C} = {95915611-30BF-4AFF-AE41-5CDC6F57DCF7}
{B1D06F62-B315-4ED8-8109-168B4D4E4B86} = {95915611-30BF-4AFF-AE41-5CDC6F57DCF7}
{898C9B2C-E43A-434F-9927-F6697C0ACE40} = {BB4A1FCC-9C83-4622-854C-987069F66BB3}
{6ECC8509-2937-4667-AECC-C20BA62D3FC5} = {BB4A1FCC-9C83-4622-854C-987069F66BB3}
{87223E5F-A0B2-4827-A4A4-B4C40BEAFBE8} = {78F7011B-1C83-4AFC-B163-32420EB10ECA}
Expand All @@ -166,6 +172,10 @@ Global
{C4F5601D-8D33-4C95-BCFD-EDEF1DC095B4} = {A1BDA50C-D70B-416C-97F1-74B0649797C5}
{7C994084-D425-487C-9266-413BB0C22695} = {A1BDA50C-D70B-416C-97F1-74B0649797C5}
{632E6195-4304-4C67-AABB-7CFC3F9086B6} = {F9DB9323-C919-49E8-8F96-B923D2F42E60}
{9C8EBDB5-FA17-4C9C-8946-04692AC752CE} = {25382551-D3BE-46C0-AAB5-8D2C64D4EDDD}
{174A36F1-27ED-43FC-A3A1-00DA58C4E30C} = {9C8EBDB5-FA17-4C9C-8946-04692AC752CE}
{2BF8EE74-1AB3-4DB8-ADDE-27A35981CA04} = {9C8EBDB5-FA17-4C9C-8946-04692AC752CE}
{431651D7-D40A-403E-813C-496A1414AA22} = {95915611-30BF-4AFF-AE41-5CDC6F57DCF7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DABA3C65-9D74-4EB6-9B1C-730328710EAD}
Expand Down
4 changes: 3 additions & 1 deletion Microsoft.AspNetCore.SystemWebAdapters.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"src\\Microsoft.AspNetCore.SystemWebAdapters\\Microsoft.AspNetCore.SystemWebAdapters.csproj",
"test\\Microsoft.AspNetCore.SystemWebAdapters.CoreServices.Tests\\Microsoft.AspNetCore.SystemWebAdapters.CoreServices.Tests.csproj",
"test\\Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices.Tests\\Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices.Tests.csproj",
"test\\Microsoft.AspNetCore.SystemWebAdapters.Tests\\Microsoft.AspNetCore.SystemWebAdapters.Tests.csproj"
"test\\Microsoft.AspNetCore.SystemWebAdapters.Tests\\Microsoft.AspNetCore.SystemWebAdapters.Tests.csproj",
"test\\Samples.MVCApp.Tests\\Samples.MVCApp.Tests.csproj",
"test\\Samples.RemoteAuth.Forms.Tests\\Samples.RemoteAuth.Forms.Tests.csproj"
]
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Yarp.ReverseProxy" Version="1.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.SystemWebAdapters.CoreServices\Microsoft.AspNetCore.SystemWebAdapters.CoreServices.csproj" />
<ProjectReference Include="..\ClassLibrary\ClassLibrary.csproj" />
</ItemGroup>
</Project>

</Project>
47 changes: 47 additions & 0 deletions samples/CoreApp/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Microsoft.AspNetCore.SystemWebAdapters;

var builder = WebApplication.CreateBuilder();

builder.Services.AddSystemWebAdapters()
.WrapAspNetCoreSession()
.AddSessionSerializer()
.AddJsonSessionSerializer(options =>
{
options.RegisterKey<int>("callCount");
});

builder.Services.AddDistributedMemoryCache();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseHttpsRedirection();

app.UseRouting();

app.UseSession();

app.UseSystemWebAdapters();

app.MapGet("/session", (HttpContext context) =>
{
var adapter = (System.Web.HttpContext)context;

if (adapter.Session!["callCount"] is not int count)
{
count = 0;
}

adapter.Session!["callCount"] = ++count;

return $"This endpoint has been hit {count} time(s) this session";
}).RequireSystemWebAdapterSession();

app.Run();
37 changes: 37 additions & 0 deletions samples/CoreApp/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:5210",
"sslPort": 44386
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5004",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7047;http://localhost:5004",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
9 changes: 9 additions & 0 deletions samples/CoreApp/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions samples/CoreApp/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
6 changes: 5 additions & 1 deletion samples/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<!-- Disable any build stuff brought in by arcade for the samples.
By default, Arcade will bring in PackageReferences which will break any old-style projects (they will prefer those packages over packages.config) -->
<Project />
<Project>
<!-- CI builds will run `dotnet test` which expects a target named test. The samples have no target for that, so this enables
an empty target so that this command will work and be a no-op for the tests. -->
<Target Name="Test"></Target>
</Project>
9 changes: 9 additions & 0 deletions samples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Samples

This folder contains samples for migrating ASP.NET Framework to ASP.NET Core using the adapters in this repo. All of these apps share the `ClassLibrary` project that has shared System.Web API usage via the adapters.

- *`CoreApp`*: This app is an ASP.NET Core application only that is still using System.Web APIs running completely on ASP.NET Core
- *`RemoteApp/*`*: These apps are ASP.NET Framework and Core application pairs that showcases using remote app authentication in the ASP.NET Core application with different auth types:
- *`RemoteApp/Bearer`*: This uses bearer authentication. Requires setting up an Azure B2C instance and filling in the values in `appsettings.json`
- *`RemoteApp/Forms`*: This uses forms based authentication
- *`RemoteApp/Identity`*: This uses ASP.NET Framework identity for authentication
Loading