發表文章

目前顯示的是 6月, 2019的文章

[IIS] http 強制轉成https 方法

開啟網站應用程式根目錄下的  web.config  設定檔,並且找到  < system.webServer >  區段,加入以下設定即可完成: <system.webServer> <rewrite> <rules> <rule name="HTTP to HTTPS redirect" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> </conditions> <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" /> </rule> </rules> </rewrite> </system.webServer> IIS7 以上請安裝 URL Rewrite https://www.iis.net/downloads/microsoft/url-rewrite

ASCII Table : XML 無效字元處理

產生XML時,會發生如一下資訊 ', hexadecimal value 0x08, is an invalid character. ', hexadecimal value 0x12, is an invalid character. 是某些字元逸出的關系 使用以下REPLACE 處理即可 private string ReplaceHexadecimalSymbols(string txt) { if(txt != "") { string r = "[\x00-\x08\x0B\x0C\x0E-\x1F]"; return Regex.Replace(txt, r, "", RegexOptions.Compiled); } else { return ""; } } ASCII Table 對照表: Dec Char Dec Char Dec Char Dec Char --------- --------- --------- ---------- 0 NUL (null) 32 SPACE 64 @ 96 ` 1 SOH (start of heading) 33 ! 65 A 97 a 2 STX (start of text) 34 " 66 B 98 b 3 ETX (end of text) 35 # 67 C