Cannot use Server.MapPath

前端 未结 8 1425
悲哀的现实
悲哀的现实 2020-12-02 10:11

What I must do to make Server.MapPath work?
I have using System.Web;

what else? When I type Server there is no quick resu

相关标签:
8条回答
  • 2020-12-02 11:05

    System.Web.HttpContext.Current.Server.MapPath("~/") gives null if we call it from a thread.

    So, Try to use

    System.Web.Hosting.HostingEnvironment.MapPath("~/")

    0 讨论(0)
  • 2020-12-02 11:07

    Firt add a reference to System.web, if you don't have. Do that in the References folder.

    You can then use Hosting.HostingEnvironment.MapPath(path);

    0 讨论(0)
提交回复
热议问题