검색결과 리스트
c#에 해당되는 글 2건
- 2021.12.23 BaseURL 가져오기
- 2020.09.04 Get IP Address with c#
글
.Net4.0 c#
public static string GetBaseUrl()
{
string protocol;
if (HttpContext.Current.Request.IsSecureConnection)
protocol = "https";
else
protocol = "http";
System.Text.StringBuilder uri = new System.Text.StringBuilder(protocol + "://");
string hostname = HttpContext.Current.Request.Url.Host;
uri.Append(hostname);
int port = HttpContext.Current.Request.Url.Port;
if (port != 80 && port != 443)
{
uri.Append(":");
uri.Append(port.ToString());
}
return uri.ToString();
}
글
public static string GetIPAddress(string hostName)
{
var host = Dns.GetHostEntry(Dns.GetHostName());
return (from ip in host.AddressList where ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork select ip.ToString()).FirstOrDefault();
}
'5.Developement' 카테고리의 다른 글
Java Script - 글자수 제한 (0) | 2019.09.25 |
---|
RECENT COMMENT