c# 取域名字串函数 GetHostName

类别: CSharp.Net, function
标签: c#, func, GetHostName, host, hostname
摘要: ..
正文:
  1. <%@ Page Language="C#" AutoEventWireup="True" %>
  2. <script runat="server">
  3.  void Page_Load(Object s, EventArgs e)
  4.  {
  5.   Response.Write(GetHostName());
  6.  } // end Page_Load
  7.  
  8.  public static string GetHostName()
  9.  {
  10.   return GetHostName(HttpContext.Current.Request.Url+"", true);
  11.  }
  12.  
  13.  public static string GetHostName(bool hasHttp)
  14.  {
  15.   return GetHostName(HttpContext.Current.Request.Url+"", hasHttp);
  16.  }
  17.  
  18.  public static string GetHostName(string url, bool hasHttp) 
  19.  {
  20.   string[] UrlSet = url.Split('/');
  21.   if(hasHttp)
  22.   {
  23.    return UrlSet[0]+"//"+UrlSet[2];
  24.   }
  25.   else
  26.   {
  27.    return UrlSet[2];
  28.   }
  29.  } // end string GetHostName
  30. </script>
  31. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  32. <html xmlns="http://www.w3.org/1999/xhtml">
  33. <!-- DW6 -->
  34. <head>
  35. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  36. <title>shawl.qiu template</title>
  37. </head>
  38. <body>
  39.  <form runat="server">

  40.  </form>
  41. </body>
  42. </html>


 
文章相关信息:
主题: c# 取域名字串函数 GetHostName
发表者: shawl.qiu
电子邮件: shawl.qiu@gmail.com
QQ: 908202921
MSN: btbtd@msn.com
Homepage: http://www.btbtd.org/
Blog: http://blog.csdn.net/btbtd/
发表日期: 2007-5-12 11:02:09
更新日期: 2007-5-12 11:02:09
来源引用: shawl.qiu CSharp DotNet 个人资料管理系统
引用本页: http://gi.2288.org/mod/code/display/Default.aspx?aid=408
关闭
Google
搜索WWW
搜索www.btbtd.org
搜索blog.csdn.net
Powered by shawl.qiu © 2008-2010 the shawl.qiu Javascript Kits
Copyright © 2008-2010 by shawl.qiu