Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting Microsoft.AspNetCore.Http.HttpContext to System.Web.HttpContext

My team is working on a new project that is built on the ASP.NET Core Web Application (.NET Framework) template. For legacy reasons we have another project that was build upon System.Web and directly accesses HttpContext via HttpContext.Current. Since our new project uses Microsoft.AspNetCore.Http.HttpContext we would like to know if its possible to convert the HttpContext to the older System.Web.HttpContext?

like image 251
Collin Price Avatar asked Oct 28 '25 05:10

Collin Price


1 Answers

'Legacy' ASP.NET and ASP.NET Core don't play well together. In fact, I'd be surprised if they do at all. Their nature and characteristics are very different. Mocking the HttpContext in the legacy ASP.NET is pretty difficult. And even if you could, it's gonna be a hell of a job to set it correctly in the HttpContext.Current without being bitten by multi-threading issues.

My suggestion is to migrate the legacy application or expose the legacy functionality via a web API and use that to communicate between the two applications.

like image 98
Henk Mollema Avatar answered Oct 31 '25 00:10

Henk Mollema



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!