随笔分类 -  .NET

.NET知识分享
摘要:public class ValidationCodeImageGenerator { //private string _charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"; private string _charset = "1234567890"; //private string[] _fontNames = { "Verdana", "Microsoft Sans Serif", "Comic S 阅读全文
posted @ 2014-01-15 14:52 silence逢场作戏 阅读(221) 评论(0) 推荐(0)
摘要:public class CookieHelper : System.Web.SessionState.IReadOnlySessionState { public static void SetCookies(HttpContext context, string cookieName, Hashtable hashtable) { HttpCookie myCookie = new HttpCookie(cookieName); foreach (DictionaryEntry de in hashtable) { myCookie.Values.Remove(de.Key.ToStrin 阅读全文
posted @ 2014-01-15 13:50 silence逢场作戏 阅读(212) 评论(0) 推荐(0)
摘要:public static string GetRealIP(){ string result = String.Empty; result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (null == result || result == String.Empty) { result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; } if (null == result 阅读全文
posted @ 2014-01-15 13:45 silence逢场作戏 阅读(186) 评论(0) 推荐(0)
摘要:using Excel = Microsoft.Office.Interop.Excel;private static Excel.Application m_xlApp = null;/// /// 将DataTable数据导出到Excel表 /// /// 要导出的DataTablepublic static void ExportExcel(System.Data.DataTable tmpDataTable) { if (tmpDataTable == null) { return; } long rowNum = tmpDataTable.Rows.Count;//行数... 阅读全文
posted @ 2014-01-15 13:39 silence逢场作戏 阅读(780) 评论(0) 推荐(0)
摘要:// /// 发送邮件 /// /// 发件人邮箱 /// 发件人密码 /// 收件人邮箱 /// 主题 /// 内容 /// public static bool SendEmail(string fromemail, string pwd, string toemail, string subject, string body) { SmtpClient client = new SmtpClient(); client.Host = "smtp." + fromemail.Remove(0, fromemail.IndexOf("@") + 1); 阅读全文
posted @ 2014-01-15 10:37 silence逢场作戏 阅读(226) 评论(0) 推荐(0)
摘要:当需要用到某个网站上的一些内容时,可以使用下面的方法,获取整个网页的内容,然后在截取自己想要的那部分private string GetWebContent(string Url){ string strResult = ""; try { //声明一个HttpWebRequest请求 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);//设置连接超时时间request.Timeout = 30000; request.Headers.Set("Pragma", "n 阅读全文
posted @ 2013-05-21 11:26 silence逢场作戏 阅读(161) 评论(0) 推荐(0)