热烈祝贺ASP.NET群7947148成立了。

解决方案 »

  1.   

    刚才看到的 
     Dim   UrlAuthority   As   String   =   
              HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority)   
      If   HttpContext.Current.Request.ApplicationPath   =   "/"   Then   
              '   直接安装在   Web   站点   
              HttpContext.Current.Session("AppPath")   =   UrlAuthority   
      Else   
              '   安装在虚拟子目录下   
              HttpContext.Current.Session("AppPath")   =   
                      UrlAuthority   &   HttpContext.Current.Request.ApplicationPath   
      End   If
      

  2.   

    我只能用html。
    ###########################我#$%^$^#@&#%%*)(^)#^$@#
      

  3.   

    不是有一种叫绝对路径的东西吗???    (非http路径)~~~~~~我只能这样写<a href='路径'></a>  只能直接写文本~~
      

  4.   

    ~/只能用在server控件和Response.Write()以及类似的代码里面
      

  5.   

    如果是写在html里面,使用"/",表示web程序的根目录。
    如果是写在后台代码里面,使用"~/"
      

  6.   

    在html里用  /
    在asp.net后台代码中,用 "~/"
      

  7.   

        public static string pathtov(string Path)
        {
            //取URL虚拟路径
            string VirtualSrc = System.Web.HttpContext.Current.Request.Url.ToString();
            int NameCut = VirtualSrc.LastIndexOf("/");
            //保存参数
            string SavePath = Path;
            string TreePath = System.Web.HttpContext.Current.Request.MapPath(@"~/");
            string UpDirectory = "";
            //截取文件名
            VirtualSrc = VirtualSrc.Remove(NameCut + 1);
            //如果HTTP带参数则保留参数
            if (Path.LastIndexOf(@"?") >= 0)
            {
                Path = Path.Remove(Path.LastIndexOf(@"?"));
                //取得上一级与上n级目录
                UpDirectory = System.Web.HttpContext.Current.Request.MapPath(Path).Replace(TreePath, "").Replace(@"\", "/").Replace(Path, "");
            }
            else
            {
                //取得上一级与上n级目录
                UpDirectory = System.Web.HttpContext.Current.Request.MapPath(Path).Replace(TreePath, "").Replace(@"\", "/").Replace(Path, "");        } 
            
            if (UpDirectory != "")
            {
                VirtualSrc = VirtualSrc.Replace(UpDirectory, "");
            }
            return VirtualSrc + SavePath;
        }这是我最近一个项目解决的方法:如你要到根目录下的某个文件可以这样调用:pathtov("js/xx.js")
    你网站的网址是:httP://www.xxx.com这个方法就会返回
    httP://www.xxx.com/js/xx.js,你现在在网站任何地方调都不会有路径问题了