none
Instrumentation Profiler in CoreCLR(.Net Core) - Ways to get HttpContext in .NetStandard assembly RRS feed

  • Question

  • I am trying to Instrument .NET Core web applications that runs on .NET Core 3.1 using CoreCLR Profiler.
    When I allow injecting the code into the Web application's method the helper assembly(.NET standard 2.0) is got attached to dotnet.exe process and it is getting callbacks to the helper assembly.
    I have created helper assembly(.NET standard 2.0) with the injected functions body.

    Now I need to get the HttpContext.Current of the each HTTP request of .NET core web application in helper assembly(.NET standard 2.0). In .Net framework we have System.Web.HttpContext.Current and System.Web.HttpRequest to get the Header,cookie,session id and site name of each request. How can I achieve same in .Net standard? 

    1. Can I use Microsoft.AspNetCore.Http.HttpRequest in .NET standard 2.0 assembly? If so how can I add reference to .Net standard assembly?
    2. How can I get Header,cookie,session id and site name of .net core web application in .NET standard 2.0 assembly?
    3. What is the alternative/equivalent of following .Net Framework namespaces in .Net Core/.Net 
         A. System.Web.HttpContext.Current
         B. System.Web.HttpRequest
         C. System.Web.HttpCookie
         D. System.Web.Hosting.HostingEnvironment.SiteName

    It would be much helpful if i get some correct direction to get or use HttpContext.Current in .NetStandard assembly.

    Thanks in advance. 

    Tuesday, March 10, 2020 2:30 PM

All replies

  • Hi Mahendra M,

    Thank you for posting here.

    After consulting with ASP.NET Core's engineer about your question, I suggest you ask your question in ASP.NET Core forums for professional help.

    Thank you for your understanding.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, March 12, 2020 10:16 AM
  • Hi Xingyu Zhao,

    Thank you for your information. I have posted the question in ASP.NET Core forum.

    Regards,

    Mahendra M.

    Friday, March 13, 2020 12:52 PM