| 类别: |
CSharp.Net, function
|
| 标签: |
c#, func, GetHostName, host, hostname
|
| 摘要: |
..
|
| 正文: |
- <%@ Page Language="C#" AutoEventWireup="True" %>
- <script runat="server">
- void Page_Load(Object s, EventArgs e)
- {
- Response.Write(GetHostName());
- } // end Page_Load
-
- public static string GetHostName()
- {
- return GetHostName(HttpContext.Current.Request.Url+"", true);
- }
-
- public static string GetHostName(bool hasHttp)
- {
- return GetHostName(HttpContext.Current.Request.Url+"", hasHttp);
- }
-
- public static string GetHostName(string url, bool hasHttp)
- {
- string[] UrlSet = url.Split('/');
- if(hasHttp)
- {
- return UrlSet[0]+"//"+UrlSet[2];
- }
- else
- {
- return UrlSet[2];
- }
- } // end string GetHostName
- </script>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <!-- DW6 -->
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>shawl.qiu template</title>
- </head>
- <body>
- <form runat="server">
- </form>
- </body>
- </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
|