Home > Software engineering >  Migrating .NET Framework to .NET Core 6 RequestBase
Migrating .NET Framework to .NET Core 6 RequestBase

Time:09-30

I have a an MVC .NET Framework 4.7.2 that I am migrating to .NET 6. The .NET Framework had a NuGet package library that was built in house (company I work for) and expected HttpRequestBase as a parameter. How would I pass in a parameter from .NET 6 to this library?

So far I am thinking that this NuGet Package will have to be upgrade to expect a parameter of Microsoft.AspNetCore.Http.HttpRequest ?

CodePudding user response:

In ASP.NET Core, I suggest you use HttpContext.

For example, getting query string in ASP.NET Core MVC:

public class HomeController: Controller
{
    public void Index(string name)
    {            
        var data = HttpContext.Request.QueryString;
    }
   
}

CodePudding user response:

My solution comes from https://www.youtube.com/watch?v=P96l0pDNVpM or you can read the article https://devblogs.microsoft.com/dotnet/incremental-asp-net-to-asp-net-core-migration/

  1. I did a test and converted my .NET Framework library to .NET Standard and added package Microsoft.AspNetCore.SystemWebAdapters.
  2. I compiled and took the DLLs to the .NET Core Web project and was able to call the method that was expecting the paramater HttpRequestBase request
  3. My .NET Core Web project did have package Microsoft.AspNetCore.SystemWebAdapters to work with converting the old project (.NET Framework MVC)
  • Related