1. 在ASP.NET中专用属性:获取服务器电脑名:Page.Server.ManchineName获取用户信息:Page.User获取客户端电脑名:Page.Request.UserHostName获取客户端电脑IP:Page.Request.UserHostAddress2. 在网络编程中的通用方法:获取当前电脑名:static System.Net.Dns.GetHostName()根据电脑名取出全部IP地址:static System.Net.Dns.Resolve(电脑名).Addre…
p>服务器IP:<%=Request.ServerVariables["LOCAL_ADDR"]%></p> <p>服务器名:<%=Request.ServerVariables["SERVER_NAME"]%></p> <p> HTTP端口:<%=Request.ServerVariables["SERVER_PORT"]%></p> <…
写在前面 在项目中经常用到解析url中参数的逻辑,今天先下载就自己封装了一个方法,方便以后使用的时候,信手拈来.当然这里给出的方法是针对常见的url参数类型的,对于重写url,或者路由格式的不考虑. c#方法 /// <summary> /// 获取url中参数 /// </summary> /// <param name="url">要解析的url</param> /// <param name="baseUrl&quo…
在Python环境下获取指定后缀文件列表的方式. 来源stackoverflow 这里简单以*.txt的作为例子. 使用glob(推荐) import glob, os os.chdir("/mydir") for file in glob.glob("*.txt"): print(file) 简单实用os.listdir import os for file in os.listdir("./mydir"): if file.endswith(…
假设当前页完整地址是:http://www.test.com/aaa/bbb.aspx?id=5&name=kelli "http://"是协议名 "www.test.com"是域名 "aaa"是站点名 "bbb.aspx"是页面名(文件名) "id=5&name=kelli"是参数 [1]获取 完整url (协议名+域名+站点名+文件名+参数) string url=Request.Url…
1 脚本编写 #!/bin/bash 2 解释 $n 表示是第几个参数 $0 表示脚本命令本身 3 执行效果…
1: Response.Write("服务器机器名:" + Server.MachineName); 2: Response.Write("<br/>"); 3: Response.Write("服务器IP地址:" + Request.ServerVariables["LOCAL_ADDR"]); 4: Response.Write("<br/>"); 5: Response.Wri…
如下: string fullpath = context.Server.MapPath("hello.htm"); //得到hello.htm的全路径 string content = System.IO.File.ReadAllText(); //读入文件内容 context.Response.Write(content); //将hello.htm的内容打出来 string username = context.Request["UserName"]; //获…
string dirPath = HttpContext.Current.Server.MapPath("uploads/"); if (Directory.Exists(dirPath)) { //获得目录信息 DirectoryInfo dir = new DirectoryInfo(dirPath); //获得目录文件列表 FileInfo[] files = dir.GetFiles("*.*"); string[] fileNames = new stri…
绝对路径 AppDomain.CurrentDomain.SetupInformation.ApplicationBase 相对路径 Server.MapPath("~/")表示当前应用级程序的目录,如果是根目录,就是根目录,如果是虚拟目录,就是虚拟目录所在的位置…