locked
Getting error The type or namespace name 'HttpRequestWrapper' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) RRS feed

  • Question

  • User2056817590 posted

    for the below code

    string path1 = ((System.Web.HttpRequestWrapper)((System.Web.HttpContextWrapper)HttpContext).Request).PhysicalApplicationPath;

    Wednesday, April 14, 2021 4:52 AM

All replies

  • User-474980206 posted

    that is correct. HttpRequest was designed correctly for DI in core so no wrapper. As a request is no longer associated with an IIS pipeline, there is no equivalent to PhysicalApplicationPath. You will need to refactor your code. Maybe assembly location will do.

    note: you keep showing code snippets, but don't explain intent. if you really need the PhysicalApplicationPath rather than the location of assemblies, then you will need to use the WMI library with a .net core wrapper.

    Wednesday, April 14, 2021 3:16 PM