Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@
Suppress warning for internal experimental APIs
-->
<NoWarn>$(NoWarn);SYSWEB1001</NoWarn>

<!-- We want to run pack on the solution so this allows us to do that -->
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
</PropertyGroup>
</Project>
271 changes: 132 additions & 139 deletions Microsoft.AspNetCore.SystemWebAdapters.sln

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions Microsoft.AspNetCore.SystemWebAdapters.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
"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.NuGet.Tests\\Microsoft.AspNetCore.SystemWebAdapters.NuGet.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"
"test\\Microsoft.AspNetCore.SystemWebAdapters.Tests\\Microsoft.AspNetCore.SystemWebAdapters.Tests.csproj"
]
}
}
}
11 changes: 4 additions & 7 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@
"dotnet": "10.0.100-preview.5.25265.106",
"runtimes": {
"dotnet": [
"6.0.4",
"7.0.12",
"8.0.1"
"8.0.16"
],
"aspnetcore": [
"6.0.4",
"7.0.12",
"8.0.1"
"8.0.16"
]
}
},
"msbuild-sdks": {
"MSBuild.SDK.SystemWeb": "4.0.88",
"MSBuild.SDK.SystemWeb": "4.0.104",
"Aspire.AppHost.Sdk": "9.3.0",
"Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.25279.3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" />
<PackageReference Include="C3D.Extensions.Aspire.IISExpress" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AuthRemoteFormsAuthCore\AuthRemoteFormsAuthCore.csproj" />
<ProjectReference Include="..\AuthRemoteFormsAuthFramework\AuthRemoteFormsAuthFramework.csproj" />
</ItemGroup>

</Project>
17 changes: 17 additions & 0 deletions samples/AuthRemoteFormsAuth/AuthRemoteFormsAuthAppHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var builder = DistributedApplication.CreateBuilder(args);

var remoteApiKey = builder.AddParameter("apiKey", Guid.NewGuid().ToString(), secret: true);

var frameworkApp = builder.AddIISExpress("iis")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL about these extensions! Preety neat!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - thanks to some great work by @CZEMacLeod!

.AddSiteProject<Projects.AuthRemoteFormsAuthFramework>("framework")
.WithDefaultIISExpressEndpoints()
.WithEnvironment("RemoteApp__ApiKey", remoteApiKey)
.WithHttpHealthCheck();

var coreApp = builder.AddProject<Projects.AuthRemoteFormsAuthCore>("core")
.WithEnvironment("RemoteApp__ApiKey", remoteApiKey)
.WithEnvironment("RemoteApp__Url", frameworkApp.GetEndpoint("https"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming the resource returned back from the above is not an IResourceWithEnvironment? Otherwise you could just do a .WithReference(frameworkApp) here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool. I'll get this merged in and then look at what can make the aspire experience better here

.WithHttpHealthCheck()
.WaitFor(frameworkApp);

builder.Build().Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:17095;http://localhost:15283",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21002",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22119"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15283",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19075",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20035"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.Dcp": "Warning"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Yarp.ReverseProxy" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\src\Microsoft.AspNetCore.SystemWebAdapters.CoreServices\Microsoft.AspNetCore.SystemWebAdapters.CoreServices.csproj" />
<ProjectReference Include="..\..\ServiceDefaults\Samples.ServiceDefaults.Core\Samples.ServiceDefaults.Core.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
var builder = WebApplication.CreateBuilder(args);

builder.Services.AddReverseProxy().LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
builder.AddServiceDefaults();

builder.Services.AddReverseProxy();

// Add services to the container.
builder.Services.AddControllersWithViews();
Expand All @@ -9,8 +11,8 @@
builder.Services.AddSystemWebAdapters()
.AddRemoteAppClient(options =>
{
options.RemoteAppUrl = new(builder.Configuration["ProxyTo"]!);
options.ApiKey = builder.Configuration["RemoteAppApiKey"]!;
options.RemoteAppUrl = new(builder.Configuration["RemoteApp:Url"]!);
options.ApiKey = builder.Configuration["RemoteApp:ApiKey"]!;
})
.AddAuthenticationClient(true);

Expand All @@ -37,6 +39,14 @@
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.MapForwarder("/{**catch-all}", app.Configuration["ProxyTo"]!).WithOrder(int.MaxValue);

// Configure the the reverse proxy to forward all unhandled requests to the remote app
app.MapForwarder("/{**catch-all}", app.Configuration["RemoteApp:Url"]!)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: If you want to also have HealthChecks enabled, you could also call here the app.MapDefaultEndpoints() from your ServiceDefaults project which should do that.


// If there is a route locally, we want to ensure that is used by default, but otherwise we'll forward
.WithOrder(int.MaxValue)

// If we're going to forward the request, there is no need to run any of the middleware after routing
.ShortCircuit();

app.Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"profiles": {
"FormsAuthCore": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7080;http://localhost:5080",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
},
"AllowedHosts": "*",
"RemoteApp": {
"Key": "23EB1AEF-E019-4850-A257-3DB3A85495BD",
"Url": "https://localhost:44305"
"ApiKey": "** PROVIDE UNIQUE KEY **",
"Url": "** URL to remote app **"
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
Expand Down Expand Up @@ -29,10 +29,20 @@ public static void RegisterBundles(BundleCollection bundles)
"~/Scripts/WebForms/MsAjax/MicrosoftAjaxTimer.js",
"~/Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js"));

// Use the Development version of Modernizr to develop with and learn from. Then, when you’re
// ready for production, use the build tool at https://modernizr.com to pick only the tests you need
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new ScriptBundle("~/bundles/jquery.js").Include(
"~/Scripts/jquery/dist/jquery.min.js"));

// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at https://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr.js").Include(
"~/Scripts/modernizr/src/Modernizr.min.js"));

bundles.Add(new ScriptBundle("~/bundles/bootstrap.js").Include(
"~/Scripts/bootstrap/dist/js/bootstrap.min.js"));

bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Scripts/bootstrap/dist/css/bootstrap.min.css",
"~/Content/site.css"));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,17 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Antlr" />
<PackageReference Include="AspNet.ScriptManager.bootstrap" />
<PackageReference Include="AspNet.ScriptManager.jQuery.UI.Combined" />
<PackageReference Include="AspNet.ScriptManager.jQuery" />
<PackageReference Include="bootstrap" GeneratePathProperty="true" CopyContent="true" />
<PackageReference Include="jQuery" CopyContent="true" />
<PackageReference Include="Microsoft.AspNet.FriendlyUrls" />
<PackageReference Include="Microsoft.AspNet.ScriptManager.MSAjax" GeneratePathProperty="true" CopyContent="true" />
<PackageReference Include="Microsoft.AspNet.ScriptManager.WebForms" GeneratePathProperty="true" CopyContent="true" />
<PackageReference Include="Microsoft.AspNet.Web.Optimization.WebForms" NoWarn="NU1602" />
<PackageReference Include="Modernizr" CopyContent="true" />
<PackageReference Include="Microsoft.Configuration.ConfigurationBuilders.Environment" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="WebGrease" />
<PackageReference Include="Microsoft.Web.Infrastructure" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\src\Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices\Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices.csproj" />
<ProjectReference Include="..\..\..\FrameworkSampleUtilities\FrameworkSampleUtilities.csproj" />
<ProjectReference Include="..\..\ServiceDefaults\Samples.ServiceDefaults.Framework\Samples.ServiceDefaults.Framework.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Configuration" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void Application_Start(object sender, EventArgs e)
.AddProxySupport(options => options.UseForwardedHeaders = true)
.AddRemoteAppServer(options =>
{
options.ApiKey = ConfigurationManager.AppSettings["RemoteAppApiKey"];
options.ApiKey = ConfigurationManager.AppSettings["RemoteApp__ApiKey"];
})
.AddAuthenticationServer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": false
"launchBrowser": true
}
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="FormsAuth.SiteMaster" %>
<%@ master language="C#" autoeventwireup="true" codebehind="Site.master.cs" inherits="FormsAuth.SiteMaster" %>

<!DOCTYPE html>

Expand All @@ -19,12 +19,12 @@
<body>
<form runat="server">
<asp:ScriptManager runat="server">
<Scripts>
<scripts>
<%--To learn more about bundling scripts in ScriptManager see https://go.microsoft.com/fwlink/?LinkID=301884 --%>
<%--Framework Scripts--%>
<asp:ScriptReference Name="MsAjaxBundle" />
<asp:ScriptReference Name="jquery" />
<asp:ScriptReference Name="bootstrap" />
<asp:ScriptReference Path="~/bundles/jquery.js" />
<asp:ScriptReference Path="~/bundles/bootstrap.js" />
<asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
<asp:ScriptReference Name="WebUIValidation.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebUIValidation.js" />
<asp:ScriptReference Name="MenuStandards.js" Assembly="System.Web" Path="~/Scripts/WebForms/MenuStandards.js" />
Expand All @@ -35,41 +35,39 @@
<asp:ScriptReference Name="Focus.js" Assembly="System.Web" Path="~/Scripts/WebForms/Focus.js" />
<asp:ScriptReference Name="WebFormsBundle" />
<%--Site Scripts--%>
</Scripts>
</scripts>
</asp:ScriptManager>

<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse" title="more options">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" runat="server" href="~/">Application name</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a runat="server" href="~/">Home</a></li>
<li><a runat="server" href="~/About">About</a></li>
<li><a runat="server" href="~/Contact">Contact</a></li>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<a class="navbar-brand" runat="server" href="~/">Application name</a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse" title="more options">
<span class="navbar-toggler-icon"></span>
</button>

<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="nav navbar-nav flex-grow-1">
<li><a class="nav-link" runat="server" href="~/">Home</a></li>
<li><a class="nav-link" runat="server" href="~/About">About</a></li>
<li><a class="nav-link" runat="server" href="~/Contact">Contact</a></li>
</ul>
<div class="nav navbar-nav navbar-right navbar-brand">
<div class="nav navbar-nav navbar-right">
<asp:LoginView ID="LoginView1" runat="server">
<LoggedInTemplate>
<loggedintemplate>
Welcome back,
<asp:LoginName ID="LoginName1" runat="server" />.
</LoggedInTemplate>
<AnonymousTemplate>
<asp:LoginName ID="LoginName1" runat="server" />
.
</loggedintemplate>
<anonymoustemplate>
Welcome, anonymous user
</AnonymousTemplate>
</anonymoustemplate>
</asp:LoginView>
<asp:LoginStatus ID="LoginStatus1" runat="server" LogoutAction="Redirect" LogoutPageUrl="~/Logout.aspx" />
</div>
</div>
</div>
</div>
<div class="container body-content" style="margin-top:50px">
</nav>
</header>
<div class="container body-content" style="margin-top: 50px">
<asp:ContentPlaceHolder ID="MainContent" runat="server">
</asp:ContentPlaceHolder>
<hr />
Expand Down
Loading
Loading