HttpContext gói gọn tất cả các thông tin HTTP.
Giả sử bạn có trang như sau:
http://localhost:57864/TinTuc/Chi-Tiet-Tin-Tuc.aspx?TieuDe=So-sanh-MacBook-Air-va-Pro-Nen-mua-MacBook-dong-nao-tot-nhat
Bây giờ chúng ta sẽ lấy thông tin từ HttpContext:
HttpContext.Current.Request.Url.AbsolutePath = "/TinTuc/Chi-Tiet-Tin-Tuc.aspx"
HttpContext.Current.Request.Url.AbsoluteUri = "http://localhost:57864/TinTuc/Chi-Tiet-Tin-Tuc.aspx?TieuDe=So-sanh-MacBook-Air-va-Pro-Nen-mua-MacBook-dong-nao-tot-nhat"
HttpContext.Current.Request.Url.Authority = "localhost:57864"
HttpContext.Current.Request.Url.DnsSafeHost = "localhost"
HttpContext.Current.Request.Url.Host = "localhost"
HttpContext.Current.Request.Url.LocalPath = "/TinTuc/Chi-Tiet-Tin-Tuc.aspx"
HttpContext.Current.Request.Url.OriginalString = "http://localhost:57864/TinTuc/Chi-Tiet-Tin-Tuc.aspx?TieuDe=So-sanh-MacBook-Air-va-Pro-Nen-mua-MacBook-dong-nao-tot-nhat"
HttpContext.Current.Request.Url.PathAndQuery = "/Chi-Tiet-Tin-Tuc.aspx?TieuDe=So-sanh-MacBook-Air-va-Pro-Nen-mua-MacBook-dong-nao-tot-nhat"
HttpContext.Current.Request.Url.Port = 57864
HttpContext.Current.Request.Url.Query = "?TieuDe=So-sanh-MacBook-Air-va-Pro-Nen-mua-MacBook-dong-nao-tot-nhat"
HttpContext.Current.Request.Url.Segments[0] = "/"
HttpContext.Current.Request.Url.Segments[1] = "TinTuc/"
HttpContext.Current.Request.Url.Segments[2] = "Chi-Tiet-Tin-Tuc.aspx"