發表文章

正規表示式整理表

正規表示式的特定字元 說明 等效的正規表示式 \d 數字 [0-9] \D 非數字 [^0-9] \w 數字、字母、底線 [a-zA-Z0-9_] \W 非  \w [^a-zA-Z0-9_] \s 空白字元 [ \r\t\n\f] \S 非空白字元 [^ \r\t\n\f]

網址url 正規表示式

"(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?" Public Shared Function RegURL(ByVal strParam As String) As Boolean Dim r As Regex = New Regex("(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?") Dim m As Match = r.Match(strParam) If m.Success And m.Length = Len(strParam) Then Return True Else Return False End If End Function

具有潛在危險 Request.Form 的值

具有潛在危險 Request.Form 的值已從用戶端..... 在Asp.Net的網站操作中,會產生『具有潛在危險 Request.Form 的值已從用戶端偵測到』此錯誤訊息之原因,通常是在PostBack後系統偵測到頁面中存在某些文字輸入欄位如TextBox、Html編輯器等文字內容中存在Html語法,因而判斷為惡意程式碼,如此來避免駭客的惡意攻擊。 此防禦功能在Asp.Net中預設是開啟的,可以透過在頁面的Page指示詞中加入或web.config獎到整個網站皆關閉防禦功能。即可避免資料送出後系統將Html語法判斷為惡意程式碼。 Page指示詞: <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb" Inherits="Test" validateRequest="False" %> web.config 設定檔的關閉方法: <system.web>          <pages validateRequest="False" /> </system.web> 開啟時,請務必將傳回的值,做處理。避免惡意程式攻擊。

{ASP.NET} 解析網址

原始網址如下 http://localhost:1984/News/Press/Content.aspx/123?id=1#toc 透過 Request 物件就提供很多屬性,可供快速取得網址的片段 Request.ApplicationPath / Request.PhysicalPath D:\Site\News\Press\Content.aspx System.IO.Path.GetDirectoryName(Request.PhysicalPath) D:\Site\News\Press Request.PhysicalApplicationPath D:\Site\ System.IO.Path.GetFileName(Request.PhysicalPath) Content.aspx Request.CurrentExecutionFilePath /News/Press/Content.aspx Request.FilePath /News/Press/Content.aspx Request.Path /News/Press/Content.aspx/123 Request.RawUrl /News/Press/Content.aspx/123?id=1 Request.Url.AbsolutePath /News/Press/Content.aspx/123 Request.Url.AbsoluteUri http://localhost:1984/News/Press/Content.aspx/123?id=1 Request.Url.Scheme http Request.Url.Host localhost Request.Url.Port 1984 Request.Url.Authority localhost:19...

postback後,頁面停留

讓頁面在postback後,scrollbar會停留原本的地方 方法有三種 01.WEB.CONFIG 在 <system.web></system.web> 之間增加節點 <pages maintainScrollPositionOnPostBack="true"></pages> 02.頁面宣告 <@page MaintainScrollPositionOnPostback="true" .......> 03.頁面CODE-BEHIND Page.MaintainScrollPositionOnPostBack = true

查詢 MS SQL 主機名

查詢 MS SQL 主機名 select   srvid,srvname,datasource   from   sysservers

Asp Response物件一覽表

收集參數 Cookies 用來設定用戶端 Cookie 值 屬性參數 Buffer 用來設定網頁的輸出置入緩衝區 ContentType 設定回應的文件型態 (HTTP Content Type) Expires 設定網頁保留(Cache)在瀏覽器的時間長度 ExpiresAbsolute 設定網頁保留 (Cache) 在瀏覽器的日期與時間 Status 回應到客戶端瀏覽器的狀態值 方法參數 AddHeader 設定 HTML 文漸的 HTTP 標頭 AppendToLog 在 Web Server 記錄檔案 (Log) 尾端,加入字串 BinaryWrite 不使用任河的字元轉換,寫入資訊至HTTP輸出 Clear 清除在緩衝區的 HTML 輸出資料 End 停止處理 .ASP 檔案,並傳回當時的狀況 Flush 立刻送出緩衝區的 HTML 文件資料 Redirect 指引客戶端瀏覽器至新的網頁 Write 寫入字串資訊至最近的 HTTP 輸出