获取站点RootURI

    public class UitlHelper
    
{
        
public static string GetRootURI()
        
{
            
string AppPath = "";
            HttpContext HttpCurrent 
= HttpContext.Current;
            HttpRequest Req;
            
if (HttpCurrent != null)
            
{
                Req 
= HttpCurrent.Request;

                
string UrlAuthority = Req.Url.GetLeftPart(UriPartial.Authority);
                
if (Req.ApplicationPath == null || Req.ApplicationPath == "/")
                    
//直接安装在   Web   站点  
                    AppPath = UrlAuthority;
                
else
                    
//安装在虚拟子目录下  
                    AppPath = UrlAuthority + Req.ApplicationPath;
            }

            
return AppPath;
        }

    }
posted @ 2009-06-11 11:07  RobertFang  阅读(303)  评论(0编辑  收藏  举报