2014-05-21 4 views
0

on on aspx.page 코드 뒤에 나는 다른 웹 페이지의 전체 URI가 필요하다! 표준 기능이 있습니까?웹 페이지의 전체 URL 얻기

그래서 내가 상대 URL

GetFullUri ("~ \ DIR2 \ link2.aspx")에 따라 전체 URI를 얻으려면 내가이 페이지에서

http:\\test.us\dir1\link1.aspx 

오전 말할

그런 다음 반환

을 http : \ test.us \ DIR2 \ link2.aspx

답변

2

상대 경로를 입력 한 다음 현재 URL을 기반으로 전체 경로를 반환하는 함수를 작성할 수 있습니다. 방법에있는 것과 같이 ~을 통과하지 마십시오

 URL used for this example: 
     http://localhost:12345/site/page.aspx?q1=1&q2=2 

     Value of HttpContext.Current.Request.Url.Host 
     localhost 

     Value of HttpContext.Current.Request.Url.Authority 
     localhost:12345 

     Value of HttpContext.Current.Request.Url.AbsolutePath 
     /site/page.aspx 

     Value of HttpContext.Current.Request.ApplicationPath 
     /site 

     Value of HttpContext.Current.Request.Url.AbsoluteUri 
     http://localhost:12345/site/page.aspx?q1=1&q2=2 

     static string (HttpContext context , string rel) 
     { 
      return HttpContext.Current.Request.Url.Scheme + "://" HttpContext.Current.Request.Url.Authority + rel; 
     } 
+0

개봉 해 주셔서 감사합니다. 왜 패스해야합니까 ~ – lordkain

+0

~ 필요한 URL의 일부가 아닙니다. – Devesh