'url'에 해당되는 글 1건

  1. 2013.06.18 [.NET] URL 프로토콜 알아내기 (HTTP,HTTPS)
posted by 네코냥이 2013. 6. 18. 14:40


Well if you are doing this in Asp.Net or have access to HttpContext.Current.Request I'd say these are easier and more general ways of getting them:

var scheme = Request.Url.Scheme; // will get http, https, etc.
var host = Request.Url.Host; // will get www.mywebsite.com
var port = Request.Url.Port; // will get the port
var path = Request.Url.AbsolutePath; // should get the /pages/page1.aspx part, can't remember if it only get pages/page1.aspx

I hope this helps. :)


http://stackoverflow.com/questions/21640/net-get-protocol-host-and-port