例如:http://www.test.com/testweb/default.aspx
取:http://www.test.com/怎么样去写

解决方案 »

  1.   

    http://www.test.com/testweb/default.aspx Request.ApplicationPath: /testweb 
    Request.CurrentExecutionFilePath: /testweb/default.aspx 
    Request.FilePath: /testweb/default.aspx 
    Request.Path: /testweb/default.aspx 
    Request.RawUrl: /testweb/default.aspx 
    Request.Url.AbsolutePath: /testweb/default.aspx 
    Request.Url.AbsoluteUri: http://www.test.com/testweb/default.aspx 
    Request.Url.Host: www.test.com 
    Request.Url.LocalPath: /testweb/default.aspx 
      

  2.   

    例如:http://www.test.com/testweb/default.aspx
    取发布部分的路径:http://www.test.com/
    例如:http://localhost:2657/testweb/default.aspx
    取:http://localhost:2657/
      

  3.   

    string s="http://"+Request.Url.Host;
    Response.Write(s);
      

  4.   

    如果考虑端口号的话:
    string s="http://"+Request.Url.Host+":"+Request.Url.Port;
    Response.Write(s);