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/
- I did a test and converted my .NET Framework library to .NET Standard and added package Microsoft.AspNetCore.SystemWebAdapters.
- 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
- My .NET Core Web project did have package Microsoft.AspNetCore.SystemWebAdapters to work with converting the old project (.NET Framework MVC)