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

搜尋意見
文章分類-darren
[所有文章分類]
  • ASP.NET (24)
  • ASP.NET2.0 (4)
  • ASP.NET4.0 (13)
  • JavaScript (17)
  • jQuery (5)
  • FireFox (2)
  • UW系統設定 (2)
  • SQL (7)
  • SQL 2008 (3)
  • mirror (0)
  • SVN (2)
  • IE (3)
  • IIS (6)
  • IIS6 (0)
  • 閒聊 (1)
  • W3C (4)
  • 作業系統 (3)
  • C# (14)
  • CSS (0)
  • FileServer (0)
  • HTML 5 (7)
  • CKEditor (0)
  • UW.dll (9)
  • Visual Studio (2)
  • Browser (2)
  • SEO (0)
  • Google Apps (1)
  • 網站輔助系統 (1)
  • DNS (0)
  • SMTP (3)
  • 網管 (5)
  • 社群API (3)
  • SSL (1)
  • App_Inventor (0)
  • URLRewrite (1)
  • 開發工具 (2)
  • JSON (0)
  • Excel2007 (0)
  • 試題 (0)
  • LINQ (0)
  • bootstrap (0)
  • Vue (0)
  • IIS7 (2)
  • foodpanda (0)
  • 編碼 (0)
  • 資安 (3)
  • Sourcetree (0)
  • MAUI (0)
  • CMD (0)
  • my sql (1)
所有文章分類
[darren的分類]
  • 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)
最新回應
  • IIS ARR (reverse proxy) 服務安裝
    ...more
  • UW DB 元件罕見的錯誤
    我之前好像也遇過, 考慮改一下 pg 的程式....more
  • UW DB物件 GetAllDataFromBaseTableWithCache 會嚴重影響效能
    我把它拿掉了....more
  • UW DB物件 GetAllDataFromBaseTableWithCache 會嚴重影響效能
    好, 把它拿掉.....more
  • 使用 facebook JS SDK 的心得筆記
    FB.login 沒有任何反應~ 不知道怎解決...more
  • IIS Server SSL 升級方式
    更新一版 reg 可以變 A...more
  • 防止 event 往上傳的終極方法
    eee...more
  • IIS Server SSL 升級方式
    Cool......more
  • UNT流量異常追蹤紀實
    有做 Request 的來源 IP 分析嗎 ? 說不定會有其它的發現.....more
  • facebook 網頁分享 Debug 模式
    Header 裡面的兩個 tag.. <meta property="og:i...more
標籤
  • rorate
  • Print
  • 內碼
  • write
  • .
  • 0
  • exception
  • 50
  • 壓縮
  • CSP
  • 728
  • db
  • 872
  • 220
  • server
  • find
  • 黑貓 EGS
  • 1
  • AD
  • response
  • 976
  • 火狐
  • 7307
  • UWInfo Blo
  • orm
  • C
  • Deadlock
  • regex
  • 黑貓 EGS
  • 70
  • List
  • for
  • inertSQL
  • CK
  • big5
  • LazyLoad
  • 超出
  • 光
  • net ORDER
  • if
  • 5151
  • ti
  • let
  • NrhnyO3Z
  • date[t],
  • UNT
  • net
  • Image
  • �
  • Referrer
頁數 1 / 3 下一頁
搜尋 結果:
IIS 讓網站 .svn 目錄不被讀取
若網站是使用 SVN update 方式更新網站,為了防止被外部讀取到 /.svn/  目錄內容
要在 web.config 片段加上以下內容

<configuration>
<system.webServer>
     <security>
         <requestFiltering>
            <hiddenSegments>
             <add segment=".svn" />
            </hiddenSegments>
         </requestFiltering>
     </security>
</system.webServer>
</configuration>


git 也是一樣的方式
可以參考此網址
https://www.petefreitag.com/item/823.cfm
 
More...
darren, 2022/7/20 下午 04:58:58
網站同時使用 C# 與 VB.net
由於早期網站都是VB.net寫的,若是直接換成 C#,就會耗費很多時間在轉換程式上
因此 ASP.NET 特別可以在同一網站同時寫 vb 跟 C#,方式是在 web.config compilation 加上設定
    <compilation debug="true" defaultLanguage="c#" targetFramework="4.0">
     <codeSubDirectories>
        <add directoryName="VB_Code"/>
        <add directoryName="CS_Code"/>
     </codeSubDirectories>
    </compilation>

也就是 VB.NET 的 code 就放到 ~\APP_Code\VB_Code 目錄
C# 的 code 就放到 ~\APP_Code\CS_Code 目錄
這樣做有兩點要注意
1.  Namespace 的命名,最好不要互相衝突, 要能夠區分出來
2.  VB_Code 與 CS_Code 放的位置有很大的影響, 因為牽涉到 compiler的先後順序,因為 VB_Code 在 CS_Code 在前面,所以 CS_Code可以叫用 VB_Code下的程式,但是 VB_Code 卻不能叫用 CS_Code 的程式,如果希望 VB_Code可以叫用 CS_Code的程式,就把設定換過來
    <compilation debug="true" defaultLanguage="c#" targetFramework="4.0">
     <codeSubDirectories>
        <add directoryName="CS_Code"/>
<add directoryName="VB_Code"/>
     </codeSubDirectories>
    </compilation>

缺點就是反過來 CS_Code不能使用 VB_Code的程式

基本上,若是舊的程式碼都在VB_Code 那就把 VB_Code 放到前面
More...
darren, 2017/5/10 下午 02:21:54
轉整數的方法需注意的地方
比較特別的地方,都在下面的程式碼後面的註解
​
Response.Write(Convert.ToInt32("94"));
Response.Write("<br/>");
Response.Write(Convert.ToInt32(94.5)); //會四捨六入五成雙
Response.Write("<br/>");
Response.Write((94.5).ToString("N0")); //會四捨五入
Response.Write("<br/>");
Response.Write((95.5).ToString("N0")); //會四捨五入
Response.Write("<br/>");
Response.Write(Convert.ToInt32(null)); //會 return 0
Response.Write("<br/>");
Response.Write(Convert.ToInt32("94.55")); //會有 exception 要先轉成 double 之類的數值
Response.Write("<br/>");
More...
darren, 2017/3/27 上午 10:47:25
System.Web.CachedPathData.ValidatePath Exception
錯誤訊息如下, 完全沒有錯誤訊息, 以及沒有錯誤的程式碼位置
 <Item time="2016-01-11T05:39:01" page="/fr/iconic-bright-cushion-spf-50-pa-nude-perfection-compact-foundation/p/5490/c/30"
url="http://www.shopunt.com/fr/iconic-bright-cushion-spf-50-pa-nude-perfection-compact-foundation/p/5490/c/30?utm_source=edm&amp;utm_medium=email&amp;utm_content=20160107_cushion_4&amp;utm_campaign=makeup&amp;OutAD_Id=5825" username="Not Member" browserName="Chrome" browserVersion="34.0" userAgent="Mozilla/5.0 (Linux; Android 5.1.1; SAMSUNG SM-N915FY Build/LMY47X) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/2.1 Chrome/34.0.1847.76 Mobile Safari/537.36" RemoteIP="37.160.206.7" Ref="No Ref" RequestType="GET" Ver="3">
    <ErrMsg>
    </ErrMsg>
    <ErrStack> 於 System.Web.CachedPathData.ValidatePath(String physicalPath)
於 System.Web.HttpApplication.PipelineStepManager.ValidateHelper(HttpContext context)</ErrStack>
    <Post>
    </Post>
    <Cookie>
    </Cookie>
</Item>

查了一下,原來網址後面多了空白 (%20) , 也就是 ? 前面多了空白
只是exception物件會自作聰明把他濾掉了,反而從 exception log 看不到資料
測試過,userd可以正常看網站,只是server會有不斷 excetion產生,有點煩
網路上雖有一些解法,但我想還是要求下廣告時,要注意網址問題


 
More...
darren, 2016/1/11 上午 09:51:49
C# difference between `==` and .Equals()
這可能是老問題了,但還是提醒一下
當用  (Object == Object) 比較時,是用 System.Object.ReferenceEquals
所以即使兩個值是一樣的,因為 reference 是不同物件, 他還是會回傳 false
http://stackoverflow.com/questions/814878/c-sharp-difference-between-and-equals

例如要比較一個 datarow 兩個欄位值

row["SDate"] = "2015-04-01";
row["EDate"] = "2015-04-01";

(row["SDate"] == row["EDate"]) ==> false
(row["SDate"].Equals(row["EDate"])) ==> true
(row["SDate"].ToString() == row["EDate"].ToString()) ==> true
More...
darren, 2015/4/14 下午 03:16:40
SqlDateTime.MinValue VS DateTime.MinValue
MS SQL 最小的 DateTime 是 1753-01-01
SqlDateTime.MinValue = 1753-01-01 00:00:00
DateTime.MinValue = 0001-01-01 00:00:00

如果要將時間塞入 DB 千萬不要小於 1753-01-01
-------------------------------------------------------
UW.DB 物件會將 null datetime 轉成 DateTime.MinValue
但再塞入 DB 時應該要將 DateTime.MinValue 換成 null 或是 SqlDateTime.MinValue
才不會出錯
 
More...
darren, 2015/1/9 上午 11:55:15
IsNumeric 以及 Convert.ToInt32(char) 要注意的狀況
最近做一些int型別轉換的時候,發現一些現象,以後寫code的時候要注意

1. VB.NET IsNumeric 用逗號可以過,例如 IsNumeric("1234,5678") ==> True
   但是轉型別 CInt or Convert.ToInt32 就會出錯,所以用 IsNumeric 不是很保險,最好用 int.TryParse

2. Convert.ToInt32(char) 會抓出該 char 的 ascii code, 而不是該文字代表的數字
   Convert.ToInt32('9') ==> 57  (C# 用單引號代表是 char)
   Convert.ToInt32("9") ==> 9
   Convert.ToInt32('A') ==> 65  (C# 用單引號代表是 char)
   Convert.ToInt32("A") ==> error: 輸入字串格式不正確。
More...
darren, 2014/10/28 下午 07:10:28
Cached DataTable 要注意的地方

網站開發,善用 Cached DataTable 可以使網站效能倍增,不必一直去資料庫抓資料。
但是使用 Cached DataTable 有一個地方要注意
就是他是 Shared 物件,表示同時有好幾個頁面都可以存取他

例如A網頁將資料抓出,然後變更裡面的DataRow資料,
另一個B網頁也會跟著變更

由於 Cached DataTable 在 Set DataRow Value 時
可能 Critical Section 沒有處理好,若真的同時多個thread 操作
會出現 Exception
(System.ArgumentOutOfRangeException: 索引超出範圍。必須為非負數且小於集合的大小。)

建議:

  • Cached DataTable 最好是只能用來讀,不要Set Value
  • 若需要Set Value,可以使用 DataTable Copy()功能,先複製出來再操作,就不會影響到原始資料

            '這是 UNT FixPage 物件抓取單一資料的範例
            Shared Function GetSpecialPage2FromCachedDT(ByVal Key As Int32) As DB.SpecialPage2
                Dim DT As DataTable = GetAllDataFromBaseTableWithCache()
                Dim Row As DataRow = DT.Rows.Find(Key)
                If Row IsNot Nothing Then
                    '避免每個thread都共用table 寫入資料會出現問題
                    Dim newDT As DataTable = DT.Clone()
                    newDT.ImportRow(Row)
                    Return New SpecialPage2(newDT.Rows(0))
                Else
                    Return Nothing
                End If
            End Function

More...
darren, 2014/9/23 下午 03:34:21
.NET Html Parser (HtmlAgilityPack)
之前做一些專案時,會有需要去爬別人的網站。
例如找出網頁某個區塊把他截錄到資料庫
HtmlAgility Pack 是不錯的工具
http://msdn.microsoft.com/zh-tw/evalcenter/ee787055.aspx

使用上,就有點像是操作 XmlDocument 一樣
一些常用的語法 SelectNodes, SelectSingleNode 幾乎一樣
也有跟 XPath 一樣的操作方法,很方便

'載入物件,bin/ 要放入 .dll
Imports HtmlAgilityPack

'*********************
Dim html As New HtmlDocument()
html.LoadHtml("...一大塊HTML,可以是整個網頁,也可以是html區塊...")

'找出所有img tag
Dim imgNodes As HtmlNodeCollection = html.DocumentNode.SelectNodes("//img")
For Each node As HtmlNode In imgNodes
    Dim strUrl As String = node.GetAttributeValue("src", "")
    ......
Next
​
More...
darren, 2014/9/23 下午 02:35:23
Convert.ToInt32 vs Int32.Parse
Convert.ToInt32 vs Int32.Parse
這兩者的差別在於 Convert 物件可傳入的值型別比較多,也可以傳入 null (Nothing) => 0
Int32.Parse只接受 string, 遇到 null (Nothing) 會引發 exception
轉換效能上 Int32.Parse 較佳,但除非是很大量的運算,兩者之間差別微乎其微

若擔心傳入的字串不是數值 會引發錯誤
除了可以使用 try catch 包起來 也可以用 Int32.TryParse 來處理

若是遇到 DB 的資料要轉換 記得要判別是不是 DBNull
Dim intCount As Integer = If(Convert.IsDBNull(row("count")), 0, Convert.ToInt32(row("count")))

// C#
int intCount = Convert.IsDBNull(row("count")) ? 0 : Convert.ToInt32(row("count"));


 
More...
darren, 2014/8/11 下午 01:45:22
|< 123 >|
頁數 1 / 3 下一頁
~ Uwinfo ~