Confused about how to use Microsoft.AspNetCore.SystemWebAdapters while trying to port from old ASP.NET website to new ASP.NET Core web app

Sameer Ranade 0 Reputation points
2024-06-07T21:23:00.4833333+00:00
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,382 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,410 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,623 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 61,181 Reputation points
    2024-06-10T00:49:04.55+00:00

    your goal is not clear. it looks like you writing a compatibly library, but not sure the purpose.

    the web adapters main goal is to port system.web.dll dependent code to .net core. especially dependent libraries that used system.web.dll. it supplies:

    • a HttpContext which has the similar methods as system.web.dll. the trick here is the abstract library is used by the .net standard code. when implemented in old framework it uses the native library, when implemented in .net core, its a new object that calls asp.net core methods. Note that the two HttpContext have different namespaces. the adapter library for core supports implicit conversion of core HttpContext to the abstract context implementation.
    • support of the common system.web utilities
    • limited support of HttpContext.Current & current user. see: https://learn.microsoft.com/en-us/aspnet/core/migration/inc/usage_guidance?view=aspnetcore-8.0
    • a Session api more like system.web.dll
    • remote authentication (call asp.net framework site for common authentication)
    • a .net core HttpApplication object with similar events to system.web.dll
    • support of system.web modules as middleware

    generally you first should migrate all dependent libraries to netstandard 2.0. this will allow them to work in both platforms.

    0 comments No comments