ASP.NET获得虚拟目录几个基本操作
例如:http://localhost/root/sub/abc.aspx
root是虚拟目录名,sub是子目录,abc.aspx是文件名
想等得到全部:Request.Url.AbsoluteUri
想得到http://localhost/:Request.Url.GetLeftPart(System.UriPartial.Authority)
想得到/root:Request.ApplicationPath
想得到/root/sub/abc.aspx:Request.RawUrl,Request.Url.AbsolutePath
想得到localhost:Request.Url.Authority
常用数据库的连接字符串
<add name="DB" connectionString="Data Source=127.0.0.1,7788;Initial Catalog=eqmis;User ID=sa;Password=;Persist Security Info=True;" providerName="System.Data.SqlClient"/>
<!--<add name="DB" connectionString="allow zero datetime=true;Data Source=127.0.0.1;Database=northwind;User Id=root;Password=123456;" providerName="MySql.Data.MySqlClient"/>-->
<!--<add name="DB" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|Northwind.mdf; User Instance=true" providerName="System.Data.SqlClient" />-->
<!--<add name="DB" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=true;Data Source=|DataDirectory|db.mdb;Jet OLEDB:Database Password=" providerName="System.Data.OleDb" />-->
<!--<add name="DB" connectionString="Data Source=|DataDirectory|db.db;Version=3" providerName="System.Data.SQLite" />-->
<!--<add name="DB" connectionString="Data Source=ORCL;Persist Security Info=True;User ID=SYSTEM;Password=;Unicode=True" providerName="System.Data.OracleClient" />-->
网页的缓存问题
<meta content="no-cache" http-equiv="pragma" />
<meta content="no-cache" http-equiv="cache-control" />
iframe的缓存问题
//有时候上面的代码对于iframe失效,必须使用一个随机数参数让浏览器认为它是另外的网页
document.getElementById("blackFrame").src="BWList.do?isBlack=1&s="+Math.random();
js验证IP和域名
/**
* 检测是否是IP地址
* @param v
* @return
*/
function isIP(v){
var patrn=/^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)(\:\d+)?$/;
if(!patrn.exec(v)){
return false;
}
return true;
}
/**
* 检测是否是域名
* @param v
* @return
*/
function isDomain(v){
var patrn=/^[\w\u4e00-\u9fa5\-_]+(\.[\w\u4e00-\u9fa5\-_]+)+([\w\u4e00-\u9fa5\-\.,@?^=%&:\/~\+#]*[\w\u4e00-\u9fa5\-\@?^=%&\/~\+#])?$/;
if(!patrn.exec(v)){
return false;
}
return true;
}
让IDE不显示控件的某个属性。在属性上加上
[Bindable(false), Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]