Time of Update: 2017-01-18
複製代碼 代碼如下:using System; using System.Collections.Generic; using System.Text; using System.IO; using System.Threading; namespace copefile { class Program {
Time of Update: 2017-01-18
開發環境:VS2005+ASP.NET AJAX 1.0 RC首先下載ASP.NET AJAX 1.0 RC安裝檔案,完成安裝後即可進行我們的AJAX之旅了。1.開啟VS2005,點擊“建立”-“檔案”-“網站”,選擇“ASP.Net-AJAX Enabled Web Site”模板,這個模板是我們安裝ASP.NET AJAX 1.0 RC後多出來的模板2.可以看到左側工具箱多了一個AJAX
Time of Update: 2017-01-18
upload.aspx 複製代碼 代碼如下: <%@ Page language="c#" Codebehind="UpLoad.aspx.cs" AutoEventWireup="false" Inherits="WebPortal.Upload" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>多檔案上傳&
Time of Update: 2017-01-18
以前一直都是用WEB Project方式開發網站,在不少地方使用PageMethods,可以說是輕車熟路了。這次想嘗試下WEB Site方式,因為修改代碼後不用編譯,再次重新整理頁面就能看到效果,這點比較方便。可是我在使用PageMethods時,卻遇到了麻煩。加好了ScriptManager,給靜態方法加上了[WebMethod]特性,可是頁面輸出就是看不到ScriptManager:( 以為是.net
Time of Update: 2017-01-18
注意:並沒有實現CSS中的圖片採集,且圖片的正則還有待完善。 複製代碼 代碼如下: using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using
Time of Update: 2017-01-18
複製代碼 代碼如下:private int GetUrlError(string curl) { int num = 200; if(this.method==1) { HttpWebRequest request=(HttpWebRequest) WebRequest.Create(new Uri(curl)); ServicePointManager.Expect100Continue=false; try { ((HttpWebResponse)request.GetResponse())
Time of Update: 2017-01-18
首先在App_GlobalResources建立resx資源檔。如: 不同語言的resx中項目應該具有相同的名稱: 中文資源項 英文資源項 完了以後就可以使用這些名值對了,複製代碼 代碼如下:<asp:Literal ID="Literal1" runat="server" Text="<%$ Resources:lang,userinfo%>" /> 或者 複製代碼 代碼如下:<%=Resources.lang.userinfo%>
Time of Update: 2017-01-18
需要引入命名空間:複製代碼 代碼如下:using System.Net; using System.IO;函數內容:複製代碼 代碼如下:/// <summary> /// 根據Url獲得源檔案內容 /// </summary> /// <param name="url">合法的Url地址</param> /// <returns></returns> public static string
Time of Update: 2017-01-18
asp.net壓縮檔夾調用樣本:rar("e:/www.jb51.net/", "e:/www.jb51.net.rar"); asp.net解壓縮rar檔案調用樣本:unrar("e:/www.jb51.net.rar", "e:/"); 複製代碼 代碼如下: using System; using System.Collections.Generic; using System.Text; using System.Diagnostics; namespace BLL { public
Time of Update: 2017-01-18
複製代碼 代碼如下:static string GetEncoding(string url) { HttpWebRequest request = null; HttpWebResponse response = null; StreamReader reader = null; try { request = (HttpWebRequest)WebRequest.Create(url); request.Timeout = 20000; request.AllowAutoRedirect =
Time of Update: 2017-01-18
複製代碼 代碼如下: using System; using System.Net; using System.Text; using System.Text.RegularExpressions; class Program { // 擷取網頁的HTML內容,根據網頁的charset自動判斷Encoding static string GetHtml(string url) { return GetHtml(url, null); } // 擷取網頁的HTML內容,指定Encoding
Time of Update: 2017-01-18
直接分析盜鏈原理:看下面用httpwatch截獲的http發送的資料 GET /Img.ashx?img=svn_work.gif HTTP/1.1 Accept: */* Referer: http://www.jb51.net/ Accept-Language: zh-cn UA-CPU: x86 Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2
Time of Update: 2017-01-18
本文章主要介紹SqlHelper使用。 每個項目都要用到資料訪問層,我做的也不例外,但是我把資料訪問層做成獨立項目,沒有什麼太大的目的,資料訪問層,僅僅做資料訪問用,不包含任何邏輯。 為什麼要使用資料訪問層? 如果不使用資料訪問層,那麼你的代碼裡會出現很多SqlConnection、SqlCommand、SqlDataReader、Open、
Time of Update: 2017-01-18
以下都以ASP.NET開發網站為例。 1、sql注入漏洞。 解決辦法:使用預存程序,參數不要用字串拼接。簡單改進辦法:使用SqlHelper和OledbHelper 2、跨站指令碼漏洞 解決辦法:“預設禁止,顯式允許”的策略。具體參考:從用戶端檢測到有潛在危險的Request.Form值,禁止提交html標記(<>等被轉義成<) 3、上傳漏洞
Time of Update: 2017-01-18
複製代碼 代碼如下:<script language="JavaScript" type="text/javascript"> //測試瀏覽器類型// var Browser = new Object(); Browser.ua = window.navigator.userAgent.toLowerCase(); Browser.ie = /msie/.test(Browser.ua); Browser.moz = /gecko/.test(Browser.ua); /******
Time of Update: 2017-01-18
複製代碼 代碼如下:using System; using System.Web; using System.Web.UI; using System.Text.RegularExpressions; namespace STH.function { /// <summary> /// UbbCode 的摘要說明。 /// </summary> public class UbbCode { Root theroot=new Root(); HttpContext
Time of Update: 2017-01-18
一般進行替換操作都這樣:複製代碼 代碼如下:str=str.replace(字串一,字串二) 不難發現一個問題,如果str要迴圈替換很多次,下一次替換時會累加上上次替換的內容,並且全遍曆一次,如果字串二很多,替換的過程就像階梯效果,越來越大,所以速度越來越慢。要解決這個問題只能找另外的方法替換這種表達方式。 如何以更高效率代替這種操作? 思路如下: 每次替換完後,在下次替換時先排除這次替換的內容,累加本次替換的內容。複製代碼 代碼如下:public Regex
Time of Update: 2017-01-18
ASP.Net是建立在微軟新一代.Net平台架構上,利用普通語言運行時(Common Language Runtime)在伺服器後端為使用者提供建立強大的企業級Web應用服務的編程架構。下面列舉了常用的27個ASP.NET中的函數集: 1、DateTime 數字型 複製代碼 代碼如下: System.DateTime currentTime=new System.DateTime(); 1.1 取當前年月日時分秒 currentTime=System.DateTime.Now; 1.2
Time of Update: 2017-01-18
複製代碼 代碼如下:using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using
Time of Update: 2017-01-18
下面是訪問記錄檔2008-8-13 14:43:22 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322) 2008-8-13 14:43:27 Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 1.1.4322) 2008-8-13 14:44:18