I’m trying to get the absolute path of certain files in a C# class. Server.MapPath works great of course for ASPX and their code-behind pages, but that doesn’t exist in another class file. I tried HostingEnvironment.MapPath(), but that complains that the relative virtual path isn’t allowed. Any thoughts?
System.Web is already imported.
The
ServerUtilityclass is available as an instance in yourHttpContext. If you’re in an environment where you know it’ll be executed inside the ASP.Net pipeline, you can useYou’ll have to import
System.Webthough.