Bagaimana mendapatkan alamat url lengkap pada halaman Aspx di code behind menggunakan C#, yang dimaksud dengan url lengkap adalah seperti dibawah ini :
"http://localhost/virtual_dir/app/page.aspx?q=blabla"
Kita bisa menggunakan Request.Url.ToString() untuk mendapatkan nilai seperti diatas, dan untuk lebih lengkapnya, dibawah adalah apa yang bisa di keluarkan dari Object Request :
Request.ApplicationPath : /virtual_dir
Request.CurrentExecutionFilePath : /virtual_dir/app/page.aspx
Request.FilePath : /virtual_dir/app/page.aspx
Request.Path : /virtual_dir/app/page.aspx
Request.PhysicalApplicationPath : d:\Inetpub\wwwroot\virtual_dir\
Request.QueryString : /virtual_dir/app/page.aspx?q=blabla
Request.Url.AbsolutePath : /virtual_dir/app/page.aspx
Request.Url.AbsoluteUri : http://localhost/virtual_dir/app/page.aspx?q=blabla
Request.Url.Host : localhost
Request.Url.Authority : localhost:80
Request.Url.LocalPath : /virtual_dir/app/page.aspx
Request.Url.PathAndQuery : /virtual_dir/app/page.aspx?q=blabla
Request.Url.Port : 80
Request.Url.Query : ?q=blabla
Request.Url.Scheme : http
Request.Url.Segments : /
virtual_dir/
app/
page.aspx
Happy Code dan jangan lupa Subscribe, Share
No comments:
Post a Comment