### Example Azure Pipelines Configuration Source: https://github.com/dotnet/systemweb-adapters/blob/main/eng/common/template-guidance.md This example demonstrates how to configure Azure Pipelines to use 1ES managed templates, specifically for handling multiple outputs by publishing artifacts to `$(Build.ArtifactStagingDirectory)`. This approach reduces security scan overhead in 1ES pipelines. ```yaml extends: template: azure-pipelines/MicroBuild.1ES.Official.yml@MicroBuildTemplate parameters: stages: - stage: build jobs: - template: /eng/common/templates-official/jobs/jobs.yml@self parameters: # 1ES makes use of outputs to reduce security task injection overhead templateContext: outputs: - output: pipelineArtifact displayName: 'Publish logs from source' continueOnError: true condition: always() targetPath: $(Build.ArtifactStagingDirectory)/artifacts/log artifactName: Logs jobs: - job: Windows steps: - script: echo "friendly neighborhood" > artifacts/marvel/spiderman.txt # copy build outputs to artifact staging directory for publishing - task: CopyFiles@2 displayName: Gather build output inputs: SourceFolder: '$(System.DefaultWorkingDirectory)/artifacts/marvel' Contents: '**' TargetFolder: '$(Build.ArtifactStagingDirectory)/artifacts/marvel' ``` -------------------------------- ### Writeable Session Protocol (Fallback) Source: https://github.com/dotnet/systemweb-adapters/blob/main/designs/remote-session.md Handles writeable sessions when HTTP2 or SSL are unavailable, requiring a GET request kept open and a subsequent PUT request. ```mermaid sequenceDiagram participant core as ASP.NET Core participant framework as ASP.NET participant store as Lock Store participant session as Session Store core ->> +framework: GET /session framework ->> session: Request session session -->> framework: Session framework -->> +store: Register active request framework -->> core: Session core ->> core: Run request core ->> +framework: PUT /session framework ->> store: Finalize session store ->> session: Persist store ->> -framework: Notify complete framework ->> -core: Persist complete framework -->> -core: Session complete ``` -------------------------------- ### Readonly Session Protocol Sequence Source: https://github.com/dotnet/systemweb-adapters/blob/main/designs/remote-session.md Retrieves session state from the framework application without locking using a single GET request. ```mermaid sequenceDiagram participant core as ASP.NET Core participant framework as ASP.NET participant session as Session Store core ->> +framework: GET /session framework ->> session: Request session session -->> framework: Session framework -->> -core: Session core ->> core: Run request ``` -------------------------------- ### Register System Web Adapters in Global.asax Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices/README.md Initialize the System Web Adapters host within the Application_Start method of an ASP.NET Framework application. ```csharp using Microsoft.AspNetCore.SystemWebAdapters.Hosting; public class MvcApplication : HttpApplication { protected void Application_Start() { HttpApplicationHost.RegisterHost(builder => { builder.AddSystemWebAdapters(); }); // ... other startup code } } ``` -------------------------------- ### Build Custom Extensions for System Web Adapters Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters.Abstractions/README.md Use this pattern when creating extension libraries that need to register services within the ISystemWebAdapterBuilder. ```csharp using Microsoft.AspNetCore.SystemWebAdapters; public static class MyAdapterExtensions { public static ISystemWebAdapterBuilder AddMyCustomFeature( this ISystemWebAdapterBuilder builder) { builder.Services.AddSingleton(); return builder; } } ``` -------------------------------- ### Configure NuGet.config for Nightly Builds Source: https://github.com/dotnet/systemweb-adapters/blob/main/README.md Optional configuration for nightly adapter builds. Points to the CI feed for the latest development versions. ```xml ``` -------------------------------- ### Register System Web Adapters in ASP.NET Framework Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Aspire.Microsoft.AspNetCore.SystemWebAdapters/README.md Use this registration within the Global.asax.cs file to enable auto-configuration in the legacy framework application. ```csharp protected void Application_Start() { HttpApplicationHost.RegisterHost(builder => { builder.AddSystemWebAdapters(); // Auto-configured }); } ``` -------------------------------- ### Enable Authentication and Authorization Events Source: https://github.com/dotnet/systemweb-adapters/blob/main/designs/http-modules.md Register additional middleware to ensure authentication and authorization events fire in the correct order within the emulated pipeline. ```diff app.UseRouting(); app.UseAuthentication(); + app.UseAuthenticationEvents(); app.UseAuthorization(); + app.UseAuthorizationEvents(); app.UseSystemWebAdapters(); ``` -------------------------------- ### Configure System.Web Adapters in Program.cs Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters/README.md Configure the System.Web adapters service and middleware in your ASP.NET Core application's Program.cs file. ```csharp var builder = WebApplication.CreateBuilder(args); builder.Services.AddSystemWebAdapters(); var app = builder.Build(); app.UseSystemWebAdapters(); app.Run(); ``` -------------------------------- ### Configure Incremental Migration in Aspire Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Aspire.Hosting.IncrementalMigration/README.md Initializes a distributed application builder and configures an ASP.NET Core project to fallback to an ASP.NET Framework project using IIS Express. ```csharp var builder = DistributedApplication.CreateBuilder(args); // Add ASP.NET Framework app with IIS Express var frameworkApp = builder.AddIISExpressProject("framework"); // Add ASP.NET Core app with fallback to Framework app var coreApp = builder.AddProject("core") .WithIncrementalMigrationFallback(frameworkApp, options => { options.RemoteSession = RemoteSession.Enabled; options.RemoteAuthentication = RemoteAuthentication.DefaultScheme; }); builder.Build().Run(); ``` -------------------------------- ### Register System Web Adapters in ASP.NET Core Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Aspire.Microsoft.AspNetCore.SystemWebAdapters/README.md Call this method in the ASP.NET Core application to apply configurations provided by Aspire. ```csharp // Automatically configured from Aspire environment builder.AddSystemWebAdapters(); ``` -------------------------------- ### Configure Aspire App Host for Incremental Migration Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Aspire.Microsoft.AspNetCore.SystemWebAdapters/README.md Use this configuration in the Aspire App Host to link the framework and core projects with incremental migration settings. ```csharp var builder = DistributedApplication.CreateBuilder(args); var frameworkApp = builder.AddIISExpressProject("framework"); var coreApp = builder.AddProject("core") .WithIncrementalMigrationFallback(frameworkApp, options => { options.RemoteSession = RemoteSession.Enabled; options.RemoteAuthentication = RemoteAuthentication.DefaultScheme; }); builder.Build().Run(); ``` -------------------------------- ### Register HttpApplication and IHttpModule in ASP.NET Core Source: https://github.com/dotnet/systemweb-adapters/blob/main/designs/http-modules.md Use AddSystemWebAdapters to configure the application and register modules. Ensure the pool size is configured to handle expected concurrent request volume. ```csharp using System.Web; using ModulesLibrary; var builder = WebApplication.CreateBuilder(args); builder.Services.AddSystemWebAdapters() // Non-generic version available if no custom HttpApplication is needed .AddHttpApplication(options => { // Size of pool for HttpApplication instances. Should be what the expected concurrent requests will be options.PoolSize = 10; // Register a module by name options.RegisterModule("Module"); }); var app = builder.Build(); app.UseSystemWebAdapters(); app.Run(); class MyApp : HttpApplication { protected void Application_Start() { ... } protected void Session_Start() { ... } protected void Begin_Request() { ... } ... } class MyModule : IHttpModule { public void Init(HttpApplication app) { ... } public void Dispose() { } } ``` -------------------------------- ### Integrate OWIN as Pipeline Middleware Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters.Owin/README.md Configure OWIN middleware to run as part of the ASP.NET Core pipeline. ```csharp app.UseOwin(owinApp => { owinApp.UseMyOwinMiddleware(); }); ``` -------------------------------- ### Add System Web Adapters to ASP.NET Core Application Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/README.md Configure services and middleware for System Web Adapters in an ASP.NET Core application. ```csharp var builder = WebApplication.CreateBuilder(args); builder.Services.AddSystemWebAdapters(); var app = builder.Build(); app.UseRouting(); app.UseSystemWebAdapters(); app.Run(); ``` -------------------------------- ### Integrate OWIN in HttpApplication Events Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters.Owin/README.md Use this pattern to match ASP.NET Framework behavior by configuring OWIN middleware within HttpApplication events. ```csharp builder.Services.AddSystemWebAdapters() .AddOwinApp(app => { app.UseMyOwinMiddleware(); }); var app = builder.Build(); app.UseSystemWebAdapters(); app.Run(); ``` -------------------------------- ### Configure Local Session State with ASP.NET Core Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/README.md Integrates local session state, backed by ASP.NET Core's session management, using System Web Adapters. ```csharp builder.Services.AddSystemWebAdapters() .AddWrappedAspNetCoreSession(); builder.Services.AddDistributedMemoryCache(); builder.Services.AddSession(); ``` -------------------------------- ### Register HTTP Modules with System Web Adapters Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/README.md Configures the System Web Adapters service to include custom HTTP modules in the ASP.NET Core application pipeline. ```csharp builder.Services.AddSystemWebAdapters() .AddHttpModules(modules => modules.Add()); ``` -------------------------------- ### Register System.Web Adapters Services Source: https://github.com/dotnet/systemweb-adapters/blob/main/README.md Register the adapter services within your ASP.NET Core application's service collection. This is a prerequisite for using the adapters. ```csharp builder.Services.AddSystemWebAdapters(); ``` -------------------------------- ### Add System.Web Adapters Middleware Source: https://github.com/dotnet/systemweb-adapters/blob/main/README.md Add the System.Web adapters middleware to your ASP.NET Core application's request pipeline. Ensure it's placed after routing but before endpoint execution. ```csharp app.UseSystemWebAdapters(); ``` -------------------------------- ### Access System.Web Types in ASP.NET Core Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters/README.md Use familiar System.Web types such as HttpContext, HttpRequest, and HttpResponse within your ASP.NET Core application. Ensure the System.Web adapters are configured. ```csharp using System.Web; var context = HttpContext.Current; var userAgent = context.Request.UserAgent; var ipAddress = context.Request.UserHostAddress; // Access session and cache context.Session?["Key"] = "Value"; context.Cache["CacheKey"] = "CacheValue"; ``` -------------------------------- ### Session State Management Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters/Generated/ExcludedApis.txt Interfaces and constructors for managing session state across framework boundaries. ```APIDOC ## Session State Adapters ### Description Defines the ISessionState interface and the constructor for HttpSessionState to enable session state access in the adapter environment. ### Constructor - HttpSessionState(Microsoft.AspNetCore.SystemWebAdapters.SessionState.ISessionState) ### Interfaces - Microsoft.AspNetCore.SystemWebAdapters.SessionState.ISessionState ``` -------------------------------- ### Configure Remote Session Server Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices/README.md Enable session state sharing with an ASP.NET Core application by configuring the remote app server and session server. ```csharp HttpApplicationHost.RegisterHost(builder => { builder.AddSystemWebAdapters() .AddRemoteAppServer(options => options.ApiKey = "your-api-key") .AddSessionServer(); }); ``` -------------------------------- ### Implement Custom Session Serialization Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters.Abstractions/README.md Implement the ISessionKeySerializer interface to define custom logic for serializing and deserializing session state data. ```csharp using Microsoft.AspNetCore.SystemWebAdapters.SessionState; public class MySessionSerializer : ISessionKeySerializer { public bool TrySerialize(string key, object? obj, out byte[] bytes) { // Implement serialization logic } public bool TryDeserialize(string key, byte[] bytes, out object? obj) { // Implement deserialization logic } } ``` -------------------------------- ### Writeable Session Protocol (HTTP2/SSL) Source: https://github.com/dotnet/systemweb-adapters/blob/main/designs/remote-session.md Uses a full-duplex POST request over HTTP2 and SSL to manage session state. ```mermaid sequenceDiagram participant core as ASP.NET Core participant framework as ASP.NET participant session as Session Store core ->> +framework: POST /session framework ->> session: Request session session -->> framework: Session framework -->> core: Session core ->> core: Run request core ->> framework: Updated session state framework ->> session: Persist framework -->> -core: Persist result (JSON) ``` -------------------------------- ### HttpContext Conversion Operators Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters/Generated/ExcludedApis.txt Implicit conversion operators between legacy System.Web.HttpContext and modern Microsoft.AspNetCore.Http.HttpContext. ```APIDOC ## Implicit Conversion: HttpContext ### Description Provides implicit conversion operators to allow seamless interoperability between legacy System.Web.HttpContext and modern Microsoft.AspNetCore.Http.HttpContext objects. ### Methods - op_Implicit(Microsoft.AspNetCore.Http.HttpContext) -> System.Web.HttpContext - op_Implicit(System.Web.HttpContext) -> Microsoft.AspNetCore.Http.HttpContext ### Usage These operators allow developers to pass modern HttpContext instances into legacy code expecting System.Web.HttpContext and vice versa. ``` -------------------------------- ### Implement and Map an HTTP Handler Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/README.md Defines a custom HTTP handler implementing `IHttpHandler` and maps it to a specific URL path in the ASP.NET Core application. ```csharp app.MapHttpHandler("/handler.ashx"); public class MyCustomHandler : IHttpHandler { public bool IsReusable => true; public void ProcessRequest(System.Web.HttpContext context) { context.Response.Write("Hello from IHttpHandler!"); } } ``` -------------------------------- ### Configure Remote Session State with ASP.NET Framework Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/README.md Enables remote session state sharing between ASP.NET Core and ASP.NET Framework applications. Requires specifying the remote app URL and an API key. ```csharp builder.Services.AddSystemWebAdapters() .AddRemoteAppClient(options => { options.RemoteAppUrl = new Uri("https://framework-app.example.com"); options.ApiKey = "your-api-key"; }) .AddSessionClient(); ``` -------------------------------- ### Integrate OWIN as Authentication Handler Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters.Owin/README.md Use OWIN middleware for authentication by configuring it as an authentication handler within ASP.NET Core's authentication services. ```csharp builder.Services.AddAuthentication() .AddOwinAuthentication(options => { options.AppBuilder = owinApp => { owinApp.UseCookieAuthentication(new CookieAuthenticationOptions()); }; }); ``` -------------------------------- ### HttpFileCollection Members Source: https://github.com/dotnet/systemweb-adapters/blob/main/test/Microsoft.AspNetCore.SystemWebAdapters.Apis.Tests/BaselineOk.txt This snippet outlines key members of the HttpFileCollection class, focusing on accessing file count and keys. ```APIDOC ## HttpFileCollection Members ### Description Provides information about accessing the count of files and the collection of keys within an HttpFileCollection. ### Method N/A (This section describes properties and methods, not a specific HTTP method) ### Endpoint N/A ### Parameters N/A ### Request Body N/A ### Response #### Success Response (N/A) N/A #### Response Example N/A ## Properties and Methods ### `Count` Property #### Description Gets the number of files in the collection. #### Type System.Int32 ### `Keys` Property #### Description Gets a collection of the names of all the files in the collection. #### Type System.Collections.Specialized.NameObjectCollectionBase.KeysCollection ### `GetEnumerator` Method #### Description Returns an enumerator that can be used to iterate through the collection. #### Return Type System.Collections.IEnumerator ``` -------------------------------- ### Configure Shared Data Protection Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices/README.md Share encryption keys between ASP.NET Framework and ASP.NET Core by persisting keys to a shared file system location. ```csharp using Microsoft.AspNetCore.DataProtection; HttpApplicationHost.RegisterHost(builder => { builder.AddDataProtection() .PersistKeysToFileSystem(new DirectoryInfo(@"C:\shared-keys")) .SetApplicationName("MySharedApp"); builder.AddSystemWebAdapters(); }); ``` -------------------------------- ### System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters/Generated/ExcludedAttributes.txt Specifies that an output is not null if the specified input argument is not null. ```APIDOC ## NotNullIfNotNullAttribute ### Description Specifies that an output is not null if the specified input argument is not null. ### Namespace System.Diagnostics.CodeAnalysis ``` -------------------------------- ### System.Runtime.CompilerServices.NullableContextAttribute Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters/Generated/ExcludedAttributes.txt Specifies the nullable context for a type or method. ```APIDOC ## NullableContextAttribute ### Description Specifies the nullable context for a type or method. ### Namespace System.Runtime.CompilerServices ``` -------------------------------- ### System.Runtime.CompilerServices.NullableAttribute Source: https://github.com/dotnet/systemweb-adapters/blob/main/src/Microsoft.AspNetCore.SystemWebAdapters/Generated/ExcludedAttributes.txt Indicates that the annotated element should be treated as nullable. ```APIDOC ## NullableAttribute ### Description Indicates that the annotated element should be treated as nullable. ### Namespace System.Runtime.CompilerServices ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.