有我自已的类中调用了MapPath, 报错.
location = System.Web.HttpContext.Current.Server.MapPath ("/");
报错:未能映射路径“/”。
我CALL这个类时不想传参数进去,可以解决吗?

解决方案 »

  1.   

    应用程序根是用
    location = System.Web.HttpContext.Current.Server.MapPath("~");
    网站的根
    location = System.Web.HttpContext.Current.Server.MapPath("/");这个应该没有是对的
      

  2.   

    location = System.Web.HttpContext.Current.Server.MapPath(".");
      

  3.   

    / 代表的是整个Web站点的根目录,相对于wwwroot.~代表的是整当前应用程序的根目录,但~只能在服务端控件上面使用.也可以考虑用Server.MapPath(".")
      

  4.   

    = System.Web.HttpContext.Current.Server.MapPath(null);