UWInfo Blog
發表新文章
[Join] | [忘記密碼] | [Login]
搜尋

搜尋意見
文章分類-#Author#
[所有文章分類]
所有文章分類
  • ASP.NET (48)
  • ASP.NET2.0 (15)
  • ASP.NET4.0 (34)
  • JavaScript (49)
  • jQuery (26)
  • FireFox (4)
  • UW系統設定 (3)
  • SQL (39)
  • SQL 2008 (25)
  • mirror (4)
  • SVN (4)
  • IE (9)
  • IIS (20)
  • IIS6 (1)
  • 閒聊 (7)
  • W3C (6)
  • 作業系統 (9)
  • C# (24)
  • CSS (12)
  • FileServer (1)
  • HTML 5 (11)
  • CKEditor (3)
  • UW.dll (13)
  • Visual Studio (16)
  • Browser (8)
  • SEO (1)
  • Google Apps (3)
  • 網站輔助系統 (4)
  • DNS (5)
  • SMTP (4)
  • 網管 (11)
  • 社群API (3)
  • SSL (4)
  • App_Inventor (1)
  • URLRewrite (2)
  • 開發工具 (6)
  • JSON (1)
  • Excel2007 (1)
  • 試題 (3)
  • LINQ (1)
  • bootstrap (0)
  • Vue (3)
  • IIS7 (3)
  • foodpanda (2)
  • 編碼 (2)
  • 資安 (3)
  • Sourcetree (1)
  • MAUI (1)
  • CMD (1)
  • my sql (1)
最新回應
  • Newtonsoft.Json.JsonConvert.DeserializeObject 失敗的情況
    test...more
  • dotnet ef dbcontext scaffold
    ...more
  • [ASP.NET] 利用 aspnet_regiis 加密 web.config
    ...more
  • IIS ARR (reverse proxy) 服務安裝
    ...more
  • [錯誤訊息] 請加入 ScriptResourceMapping 命名的 jquery (區分大小寫)
    ...more
  • 用 Javascript 跨網頁讀取 cookie (Cookie cross page, path of cookie)
    ...more
  • 線上客服 - MSN
    本人信箱被盜用以致資料外洩,是否可以請貴平台予以協助刪除該信箱之使用謝謝囉...more
  • 插入文字到游標或選取處
    aaaaa...more
  • IIS 配合 AD (Active Directory) 認証, 使用 .Net 6.0
    太感謝你了~~~你救了我被windows 認證卡了好幾天QQ...more
  • PostgreSQL 的 monitor trigger
    FOR EACH ROW 可能要改為 FOR EACH STATEMENT ...more
標籤
  • orm
  • [t]
  • canvas
  • -7384
  • Image
  • MScvKiovYW
  • 具有潛在危險 Req
  • write
  • pg2008
  • 8855-8767
  • 166
  • SQL2008
  • Operation
  • Linq
  • z-index
  • a
  • 上傳檔案太大
  • ses,
  • 174
  • js UNION A
  • html
  • debugWAITF
  • 7826-7738
  • background
  • iis
  • CSP
  • 186
  • config,
  • tls1.0
  • 4983
  • 1002121121
  • orderby
  • 126
  • -9649 UNIO
  • UNT
  • 旋轉
  • bitmap
  • -9971 BnYT
  • ip
  • sysconfig,
  • weget
  • ajmynshnwb
  • 62expr 952
  • machineKey
  • validation
  • union21211
  • recovery O
  • my sql
  • minvalue[t
  • iis 8
頁數 3 / 5 上一頁 下一頁
搜尋 結果:
SqlDependency 之 Stored Procedure
SqlDependency 的原理是對某些目標 table 設定所謂的 ChangeId
資料存在 dob.[AspNet_SqlCacheTablesForChangeNotification]
當目標 Table 有 Insert, Update, Delete 時會 Trigger 把 ChangeId + 1
而前端網站就是不斷定時詢問此 [AspNet_SqlCacheTablesForChangeNotification] 的 ChangeId


-- 新增目標 Table 加入 SqlDependency (此範例 MenuFirst是 table name)
Exec dbo.AspNet_SqlCacheRegisterTableStoredProcedure N'MenuFirst'

-- 直接變更 ChangeId (效果等同於去變更該table資料)
-- 會去將 ChangeId + 1
EXEC dbo.AspNet_SqlCacheUpdateChangeIdStoredProcedure N'MenuFirst'


AspNet_SqlCacheUpdateChangeIdStoredProcedure 通常是不需要做的
因為目標table都有設定 Trigger
但是在某些狀況下 目標table資料沒有變更 但是也希望前端cache要更新
就可以用此 SP
 
More...
darren, 2014/1/21 下午 12:25:33
IndexOf 效能問題
一直覺得 UW.Template 應該還有改善的空間,因為網站大量使用這個物件
只要有一些些效能調教,對於整體效能應該有很大的幫助

昨天發現切版的程式 UW.Template => GetTemplateFromString
在使用 IndexOf 去尋找 <!--Key S--> 及 <!--Key E--> 時,
<!--Key E--> 可能有一些問題,因為他是從第0個位置開始找
而實際上他應該是從 <!--Key S--> 後面開始找比較對
所以後者的 IndexOf 要加個 StartIndex 參數值比較對


    StartP = StartP + StartKey.Length
    Dim EndP As String = Source.IndexOf(EndKey, StringComparison.OrdinalIgnoreCase)
    ' 應該修改為以下寫法 =>
    StartP = StartP + StartKey.Length
    Dim EndP As String = Source.IndexOf(EndKey, StartP, StringComparison.OrdinalIgnoreCase)    


另外 我也針對 StringComparison 做一些測試 
然後以一個 20KB 的 html 去抓出 <!--Content E--> 的位置
測試結果如下 (StartP 是 <!--Content S--> 後的起始位置)


0.0005085 No StartP
0.0002082 with StartP
0.0000157 StringComparison.Ordinal with StartP
0.0002768 StringComparison.OrdinalIgnoreCase, No StartP
0.0001105 StringComparison.OrdinalIgnoreCase with StartP
0.0002116 StringComparison.CurrentCulture with StartP
0.0002085 StringComparison.CurrentCultureIgnoreCase with StartP


結論: 
1. IndexOf 預設是以 StringComparison.CurrentCulture 方式尋找字串
2. 對於大塊字串,請盡量用 StartP 去找結束標籤位置,這樣速度會快很多,因為少爬了一段文字,此範例是差了2.5倍
3. 對於大塊字串,除非大小寫都要找,不然盡量用 StringComparison.Ordinal 來尋找字串,速度差了7~8倍

微軟對於.NET字串處理 有一篇建議文章,請大家拜讀一下
http://msdn.microsoft.com/zh-tw/library/vstudio/dd465121(v=vs.100).aspx
More...
darren, 2014/1/14 下午 03:18:14
Global 網站使用 CultureInfo 物件
製作 Global 網站時,由於User來自世界各地
而各地對於時間格式以及貨幣,數字顯示方式都有所不同
這時就需要 .NET Globalization -> CultureInfo 來處理這個問題
CultureInfo 是基於 Language Code 來的
而 user 的 Language Code 基本上瀏覽器會放在 Request Header 送到Server
(ex. Accept-Language: zh-TW,zh;q=0.8,en-US;q=0.6,en;q=0.4)

        Dim d As Date = Now
        Dim n As Decimal = 86400.99
        Dim Cultures() As String = {"zh-TW", "pt-BR", "pt-PT", "en-US", "en-GB", "fr-FR", "de-DE", "es-ES", "ja-JP", "zh-CN", "ko-KR", "en-IN"}
        For i As Integer = 0 To Cultures.GetUpperBound(0)
            Dim c As New Globalization.CultureInfo(Cultures(i))
            Response.Write(Cultures(i) & "<br/>" & d.ToString("D", c) & " <br/>" & d.ToString("d", c) & "<br/>" & n.ToString("C", c))
            Response.Write("<hr/>")
        Next


結果如下:

zh-TW
2013年12月25日
2013/12/25
NT$86,400.99

pt-BR
quarta-feira, 25 de dezembro de 2013
25/12/2013
R$ 86.400,99

pt-PT
quarta-feira, 25 de Dezembro de 2013
25-12-2013
86.400,99 €

en-US
Wednesday, December 25, 2013
12/25/2013
$86,400.99

en-GB
25 December 2013
25/12/2013
£86,400.99

fr-FR
mercredi 25 décembre 2013
25/12/2013
86 400,99 €

de-DE
Mittwoch, 25. Dezember 2013
25.12.2013
86.400,99 €

es-ES
miércoles, 25 de diciembre de 2013
25/12/2013
86.400,99 €

ja-JP
2013年12月25日
2013/12/25
¥86,401

zh-CN
2013年12月25日
2013/12/25
¥86,400.99

ko-KR
2013년 12월 25일 수요일
2013-12-25
₩86,401

en-IN
25 December 2013
25-12-2013
₹ 86,400.99
More...
darren, 2013/12/26 下午 04:04:39
善用 Request.Cookies.Set After Respnse.Cookies.Add
ASP.NET程式開發時,有時候會寫資料到cookies
這時我們會用 Response.Cookies.Add 寫入
但是大家都會忽略到一種情況,如果後面程式也會使用到該cookies時
Request.Cookies 會抓不到剛設定的cookies
這時就要 Request.Cookies.Set 來設定 Request 值

錯誤示範:
Page_Load --> Response.Cookies.Add a Cookie named "test"
Page_PreRender --> Request.Cookies("test") --> Nothing 

正確示範(同時寫兩行):
Page_Load --> Response.Cookies.Add a Cookie named "test"
              Request.Cookies.Set a Cookie named "test" 
Page_PreRender --> Request.Cookies("test") --> Got it!

 
More...
darren, 2013/11/4 下午 06:37:03
Method 'get_EnableCdn' in type 'System.Web.UI.ScriptManager' from assembly 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.

解法:

http://stackoverflow.com/questions/5341324/method-get-enablecdn-in-type-system-web-ui-scriptmanager-from-assembly-syst
More...
Reiko, 2013/9/11 下午 12:22:32
DataTable 的 Rows.Find 效能較佳
因為 SHOPUNT 的線上產品有兩千多筆,然後網站有非常頻繁的查詢
例如檢查產品是否停賣

原本的寫法是用以下方法尋找

DT.Select("Id=" & ProductId) 


後來改寫 DataTable 加上 PrimaryKey

'寫入Cache前先設定好
DT.PrimaryKey = New DataColumn() {obj.Columns("Id")} 
Dim row As DataRow = DT.Rows.Find(ProductId)


共1085筆 找出其中一筆 
Select方法  - 00:00:00.0000559
Rows.Find -   00:00:00.0000064

兩者速度差了約10倍
 
More...
darren, 2013/9/5 上午 11:58:39
IIS 7 & 7.5 的動態壓縮設定
關於IIS 7 (7.5)設定動態壓縮,如何啟用這裡就不用多敘述
只是他如何判別哪些動態內容要壓縮,哪些內容不壓縮呢?
這些設定其實在 applicationHost.config 設定
位置: C:\Windows\System32\inetsrv\Config\applicationHost.config
區段:
        
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
    <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
    <staticTypes>
        <add mimeType="text/*" enabled="true" />
        <add mimeType="message/*" enabled="true" />
        <add mimeType="application/x-javascript" enabled="true" />
        <add mimeType="application/atom+xml" enabled="true" />
        <add mimeType="application/xaml+xml" enabled="true" />
        <add mimeType="application/json" enabled="true" />
        <add mimeType="*/*" enabled="false" />
    </staticTypes>
    <dynamicTypes>
        <add mimeType="text/*" enabled="true" />
        <add mimeType="message/*" enabled="true" />
        <add mimeType="application/x-javascript" enabled="true" />
        <add mimeType="application/json" enabled="true" />
        <add mimeType="*/*" enabled="false" />
    </dynamicTypes>
</httpCompression>

其中,<add mimeType="application/json" enabled="true" /> 是我自己加上的,不是系統預設的
當然,決定哪些靜態檔要壓縮也在 <staticTypes> 這裡設定
IIS 的 mime對應最好也加上 *.json -> application/json
 
More...
darren, 2013/8/8 下午 01:59:01
SessionState 效能影響問題
昨天Peter提到同一個 Session 只能一次 Request一個 Page
發現這篇文章有描述 http://blog.darkthread.net/post-2011-08-27-aspx-session-lock.aspx
主要是為了保持Session Data一致性 所以要 Lock Session

所以網頁綁 SessionState 是會影像效能的,尤其使用 StateServer 或 SqlServer 方式影響更大
一般.aspx 預設是有的,所以 aspx 有個 EnableSessionState 可以處理是否綁 SessionState
True: 可 Read, Write
ReadOnly: 可 Read
False: 完全不綁定 Session
如果網頁完全用不到 Session,可以考慮把她關閉,效能會好一點,但要注意相關程式碼、元件是否有用到,不然會有Exception

另外 web handler (.ashx) 預設是不綁 Session 的,對於單純的程式處理(例如 Ajax),建議用.ashx
但是在某些狀況下,.ashx 可能需要用到 Session
這時就要import( or using) Web.SessionState, 然後 Class 實作 IRequiresSessionState Interface
就OK啦
More...
darren, 2013/7/12 上午 10:24:57
Response.Redirect throws an “Thread was being aborted”
當我們用 try catch 去包程式時,要注意不要讓程序結束跳出
這樣會引發 Thread was being aborted 錯誤
例如 try catch 不要做 Respnse.Redirect 動作
請參考此文章
 
More...
darren, 2013/3/15 上午 11:21:31
VB 的日期常數
Optional TF As Date = #12/30/2000#
More...
Bike, 2012/11/21 下午 07:18:17
|< 12345 >|
頁數 3 / 5 上一頁 下一頁
~ Uwinfo ~