Click(Link,My Playing Station)

获取web应用程序路径

Posted on 2007-09-19 12:12  倒骑驴的人生  阅读(735)  评论(1)    收藏  举报

 

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;

namespace testurl
{
    
public class testurl
    {
        
//   获取当前的主机名称和应用程序路径   
          private   static   string   UrlSuffix   
          {   
              
get   
              {   
                  
string   host   =   HttpContext.Current.Request.Url.Host;   
                  
string   path   =   HttpContext.Current.Request.ApplicationPath;   
                  
return   host   +   path;   
              }   
          }   
    
          
///   <summary>   
          
///   属性,用于获取Urls的前缀   
          
///   </summary>   
          public   static   string   PathPrefix   
          {   
              
get   
              {   
                  
string   urlSuffix   =   UrlSuffix;   
    
                  
if   (urlSuffix.EndsWith("/"))   
                  {   
                      
int   length   =   urlSuffix.Length   -   1;   
                      urlSuffix   
=   urlSuffix.Substring(0,   length);   
                  }   
    
                  
return   @"http://"   +   urlSuffix;   
              }   
          }

        
/// <summary>
        
/// 绝对路径
        
/// </summary>
        public static string appMapPath
        {
            
get 
            {
                
string path = HttpContext.Current.Request.MapPath(HttpContext.Current.Request.ApplicationPath);
                
return path;
            }
        }
    }
}

 

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3

Click(Link,My Playing Station)