tag:blogger.com,1999:blog-87675757727502262422024-02-21T03:34:24.188+08:00Rex dotNET學習筆記Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.comBlogger130125tag:blogger.com,1999:blog-8767575772750226242.post-57332059676285818492021-09-14T21:32:00.008+08:002021-09-14T21:33:08.717+08:00net framework 3.5程式使用TLS 1.2連線<p><a href="https://docs.microsoft.com/zh-tw/mem/configmgr/core/plan-design/security/enable-tls-1-2-client#configure-for-strong-cryptography">https://docs.microsoft.com/zh-tw/mem/configmgr/core/plan-design/security/enable-tls-1-2-client#configure-for-strong-cryptography</a></p><p>SchUseStrongCrypto 設定允許 .NET 使用 TLS 1.1 和 TLS 1.2。 SystemDefaultTlsVersions 設定允許 .NET 使用 OS 設定。 <br /><br /><br />.NET 3.5 TLS 1.2 踩雷記-黑暗執行緒<br /><a href="https://blog.darkthread.net/blog/net35-tls12-issue/">https://blog.darkthread.net/blog/net35-tls12-issue/</a><br /></p>Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-42128155402209905152021-08-28T23:38:00.025+08:002021-09-02T16:42:07.612+08:00SQL Server 2012 Native Client - QFE才支援TLS 1.2<p>某次SQL Server伺服器作業系統關閉TLS 1.0和1.1之後,AP程式連DB有問題,後來發現是要安裝新版的SQL Server 2012 Native Client - QFE。原本是安裝舊版的11.0.2100.60(在2012年發佈的)。安裝後需要重新啟動伺服器。<br /><br /></p><p><b>下載Microsoft® SQL Server® 2012 Native Client - QFE (支援TLS 1</b><b><b>.</b>2)</b><br /><a href="https://www.microsoft.com/en-us/download/details.aspx?id=50402">https://www.microsoft.com/en-us/download/details.aspx?id=50402</a><br /><br />Version:<br />11.0.<span style="color: red;">7001</span>.0<br /><br />Date Published:<br />1/19/2018<br /></p><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW1BoJwBwaGHg0rn50MCKkVg16kuAGROq9sADl2008GOWC1N1wy4E4CRHFV4dGbunqRf2DM1JUkZgYIjAzAO3dp9HoQpTir6heJbpdVMH8WX94j1ckSG2VyjYS2qeClPDHC5zrYWQR65E/s596/SQL+Server+2012+Native+Client+-+QFE.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="413" data-original-width="596" height="222" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW1BoJwBwaGHg0rn50MCKkVg16kuAGROq9sADl2008GOWC1N1wy4E4CRHFV4dGbunqRf2DM1JUkZgYIjAzAO3dp9HoQpTir6heJbpdVMH8WX94j1ckSG2VyjYS2qeClPDHC5zrYWQR65E/s320/SQL+Server+2012+Native+Client+-+QFE.png" width="320" /></a></div><p><br /><br /><b>升級成新版可以在AP伺服器建立一個 .udl檔案測試和資料庫連線,可參考以下網址</b><br /><a href="https://success.trendmicro.com/solution/1118930-using-tlsv1-1-or-tlsv1-2-for-communication-between-mssql-server-and-officescan">https://success.trendmicro.com/solution/1118930-using-tlsv1-1-or-tlsv1-2-for-communication-between-mssql-server-and-officescan</a></p><p> <br /><b>KB3135244 - TLS 1.2 support for Microsoft SQL Server</b><a href="https://support.microsoft.com/en-us/topic/kb3135244-tls-1-2-support-for-microsoft-sql-server-e4472ef8-90a9-13c1-e4d8-44aad198cdbe"><b style="-webkit-text-stroke-width: 0px; color: black; font-family: "Times New Roman"; font-size: medium; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; letter-spacing: normal; orphans: 2; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"><span style="color: red;">(必看!)</span></b><br />https://support.microsoft.com/en-us/topic/kb3135244-tls-1-2-support-for-microsoft-sql-server-e4472ef8-90a9-13c1-e4d8-44aad198cdbe</a><br /></p><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiq6eD9_yStRvfaZkM-2FZ9L_zspZNsPRid8ym3mweKe92GlbiQhKG9JeqB0br17ydb648ikH11szHYJDrU6sguC84br0cOhgoB8YovJ170O-4OHd6UrE7_azgJuYtQxJwoHNgqLMnY4E0/s850/image001.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="383" data-original-width="850" height="144" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiq6eD9_yStRvfaZkM-2FZ9L_zspZNsPRid8ym3mweKe92GlbiQhKG9JeqB0br17ydb648ikH11szHYJDrU6sguC84br0cOhgoB8YovJ170O-4OHd6UrE7_azgJuYtQxJwoHNgqLMnY4E0/s320/image001.png" width="320" /> </a></div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: left;"><b><br />sqlncli.msi安裝程式資訊(</b><b><b>QFE版</b></b><b><b>,</b>支援TLS1.2)<br /></b></div><div class="separator" style="clear: both; text-align: left;"><b></b></div><div class="separator" style="clear: both; text-align: left;"><b></b></div><div class="separator" style="clear: both; text-align: left;"><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg617v9wHVGPzhs5dwufL81_achQ1pKUuIjtm6ACdsDpCpvHJfnOL6HGIidPvtU3Tzm6XjQlAM3_C__GbJm9yXIl_CJB6YXFogtQDrVwd9NX3X64ACWbZg2kreJMO7AisSFdKpHbs-AdnQ/s327/sqlncli%25E5%25AE%2589%25E8%25A3%259D%25E7%25A8%258B%25E5%25BC%258F%25E8%25B3%2587%25E8%25A8%258A_QFE%25E7%2589%2588.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="327" data-original-width="320" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg617v9wHVGPzhs5dwufL81_achQ1pKUuIjtm6ACdsDpCpvHJfnOL6HGIidPvtU3Tzm6XjQlAM3_C__GbJm9yXIl_CJB6YXFogtQDrVwd9NX3X64ACWbZg2kreJMO7AisSFdKpHbs-AdnQ/s320/sqlncli%25E5%25AE%2589%25E8%25A3%259D%25E7%25A8%258B%25E5%25BC%258F%25E8%25B3%2587%25E8%25A8%258A_QFE%25E7%2589%2588.png" width="313" /></a></div><b><br /></b><br /><b><b>sqlncli.msi安裝程式資訊(</b><b><b>舊版</b></b><b><b>,不</b>支援TLS1.2)</b> <br /></b></div><div class="separator" style="clear: both; text-align: left;"><b> </b></div><div class="separator" style="clear: both; text-align: left;"><b><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgElMJ3qTzz0azg_eSWdJaiIkhItFTNIbKVEVS9O4nf7rBH6uqAH55dsJ5BX6v9d636forBsN1VqB3IZtWyhCMlBcZOYwa7YW7-kRkvBVrBnkFdykHsPeX3ivTbY6XHWy8HHIvk6wTET1I/s406/sqlncli%25E5%25AE%2589%25E8%25A3%259D%25E7%25A8%258B%25E5%25BC%258F%25E8%25B3%2587%25E8%25A8%258A_%25E8%2588%258A%25E7%2589%2588.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="324" data-original-width="406" height="255" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgElMJ3qTzz0azg_eSWdJaiIkhItFTNIbKVEVS9O4nf7rBH6uqAH55dsJ5BX6v9d636forBsN1VqB3IZtWyhCMlBcZOYwa7YW7-kRkvBVrBnkFdykHsPeX3ivTbY6XHWy8HHIvk6wTET1I/s320/sqlncli%25E5%25AE%2589%25E8%25A3%259D%25E7%25A8%258B%25E5%25BC%258F%25E8%25B3%2587%25E8%25A8%258A_%25E8%2588%258A%25E7%2589%2588.png" width="320" /></a></div><br /></b></div><div class="separator" style="clear: both; text-align: left;"><b> </b></div><div class="separator" style="clear: both; text-align: left;"><b> </b></div><div class="separator" style="clear: both; text-align: left;"><b>AP程式的錯誤訊息(Crystal Report版本是11.5,AP</b><b><b><b>伺服器</b></b>安裝舊版</b><b><b>sqlncli.msi</b></b><b><b>,DB伺服器已關閉TLS 1.0和1.1</b>):</b><br /><br />System.Runtime.InteropServices.COMException (0x8004100F): Logon failed.<br /><br />Details: [Database Vendor Code: 10054 ]<br /><br />Logon failed.<br /><br />Details: [Database Vendor Code: 10054 ]<br /><br />Error in File C:\Windows\TEMP\XXXXX.rpt:<br /><br />Unable to connect: incorrect log on parameters.<br /><br />Details: [Database Vendor Code: 10054 ]<br /><br /> at CrystalDecisions.ReportAppServer.Controllers.DatabaseControllerClass.SetTableLocation(ISCRTable CurTable, ISCRTable NewTable)<br /><br /> at CrystalDecisions.CrystalReports.Engine.Table.set_Location(String value)</div><div class="separator" style="clear: both; text-align: left;"> </div><div class="separator" style="clear: both; text-align: left;"> <br /></div><div class="separator" style="clear: both; text-align: left;"> </div><div class="separator" style="clear: both; text-align: left;"><b>Event Log的錯誤訊息:</b></div><div class="separator" style="clear: both; text-align: left;"><b><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbc96vDJZG0jbqCS2WI_psTeIiSgFB1zkTGfFJdbNz_l85mDmGP0spcWvQRNkJilBd94aocwKSsHZJj9PvKHTEm9zLS_J39wY5j-2swy0CRU_0wBkJBG4TDiV6vslhn5ohTgMdnE8n8mo/s1427/EventLog%25E7%259A%2584%25E9%258C%25AF%25E8%25AA%25A4%25E8%25A8%258A%25E6%2581%25AF.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="764" data-original-width="1427" height="171" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbc96vDJZG0jbqCS2WI_psTeIiSgFB1zkTGfFJdbNz_l85mDmGP0spcWvQRNkJilBd94aocwKSsHZJj9PvKHTEm9zLS_J39wY5j-2swy0CRU_0wBkJBG4TDiV6vslhn5ohTgMdnE8n8mo/s320/EventLog%25E7%259A%2584%25E9%258C%25AF%25E8%25AA%25A4%25E8%25A8%258A%25E6%2581%25AF.png" width="320" /></a></div> </b></div><div class="separator" style="clear: both; text-align: left;"> </div><div class="separator" style="clear: both; text-align: left;"> <br /><br /></div><div class="separator" style="clear: both; text-align: left;"><b><br />如果有用到ODBC Driver 11 for SQL Server(msodbcsql.msi)也需要新版才支援TLS1.2<br /><<a href="https://docs.microsoft.com/zh-tw/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver15">最新版已經出到17</a>)<br /> </b><a href="https://docs.microsoft.com/zh-tw/sharepoint/security-for-sharepoint-server/enable-tls-1-1-and-tls-1-2-support-in-sharepoint-server-2016">https://docs.microsoft.com/zh-tw/sharepoint/security-for-sharepoint-server/enable-tls-1-1-and-tls-1-2-support-in-sharepoint-server-2016</a><br /><h3 class="heading-anchor" id="11---install-odbc-driver-11-for-sql-server-update-for-tls-12-support">1.1 - 安裝 ODBC Driver 11 for SQL Server 的 TLS 1.2 支援更新</h3>
<p><a name="ODBC1.1"> </a></p>
<p>ODBC Driver 11 for SQL Server (適用於 SQL Server 的 ODBC 驅動程式 11) 預設不支援
TLS 1.1 或 TLS 1.2。您必須安裝 ODBC Driver 11 for SQL Server 的 TLS 1.2 支援更新。</p>
<ul><li>若要安裝 ODBC Driver 11 for SQL Server 的 TLS 1.2 支援更新,請參閱<<a data-linktype="external" href="https://www.microsoft.com/download/details.aspx?id=36434">Microsoft® ODBC Driver 11 for SQL Server® - Windows</a>>。</li></ul><b></b></div><div class="separator" style="clear: both; text-align: left;"><b></b></div><div class="separator" style="clear: both; text-align: left;"><b><br /><br /><span style="color: red;">檢測工具(</span></b><b><span style="color: red;">CheckClientUpdates.ps1)</span><br /></b><a href="https://github.com/Microsoft/tigertoolbox/tree/master/tls1.2">https://github.com/Microsoft/tigertoolbox/tree/master/tls1.2</a></div><div class="separator" style="clear: both; text-align: left;">CheckClientUpdates.ps1<br />The PowerShell Script currently supports the following:<br /><br />Check if SQL Server Native Client can support TLS 1.2<br />Check if Microsoft ODBC Driver for SQL Server can support TLS 1.2 This script is restricted to work on x64 and x86 platforms<b><br /></b></div><div class="separator" style="clear: both; text-align: left;"><b><br /></b></div><div class="separator" style="clear: both; text-align: left;"><br /><b><span style="-webkit-text-stroke-width: 0px; color: black; display: inline !important; float: none; font-family: "Times New Roman"; font-size: medium; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">在AP伺服器上檢測SQL Server資料庫驅動程式是否支援TLS 1.2?</span></b></div><div class="separator" style="clear: both; text-align: left;">支援TLS 1.2<b><br /></b></div><div class="separator" style="clear: both; text-align: left;"><div class="separator" style="clear: both; text-align: left;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQhs4-AVOaxpbqiJr4KRjjiDJq6jJ8_CRDbC9Kt43WL47YVOpi_uOcEysCOfuFGMyyDwd1XQp19C4e6yFQwZjXuzPoSjlJtKy3A7iVxu940c1SWWZvUvt02Td8ofy8MbnHFtGQWRLAwEE/s591/CheckClientUpdates-%25E6%2594%25AF%25E6%258F%25B4TLS1.2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="80" data-original-width="591" height="43" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQhs4-AVOaxpbqiJr4KRjjiDJq6jJ8_CRDbC9Kt43WL47YVOpi_uOcEysCOfuFGMyyDwd1XQp19C4e6yFQwZjXuzPoSjlJtKy3A7iVxu940c1SWWZvUvt02Td8ofy8MbnHFtGQWRLAwEE/s320/CheckClientUpdates-%25E6%2594%25AF%25E6%258F%25B4TLS1.2.png" width="320" /></a></div><br /><b><br /></b></div><div class="separator" style="clear: both; text-align: left;">不支援TLS 1.2</div><div class="separator" style="clear: both; text-align: left;"><div style="text-align: left;"><b><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVFV7rJwVRkzQgiImRYKTRb-UL00J1sH5pkAuYYTTAl2Uuh3FM4Ngjr4QZSox110Gi5XGkwO1d2AcZWNB5K-KeQu4rkrJgQDfYBY3FxSPmmAPRSiI-RmFG8zsVyQXjiTmXYtoCYXOmJno/s732/CheckClientUpdates-%25E5%2581%25B5%25E6%25B8%25AC%25E5%2587%25BA%25E4%25B8%258D%25E6%2594%25AF%25E6%258F%25B4TLS1.2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="82" data-original-width="732" height="36" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVFV7rJwVRkzQgiImRYKTRb-UL00J1sH5pkAuYYTTAl2Uuh3FM4Ngjr4QZSox110Gi5XGkwO1d2AcZWNB5K-KeQu4rkrJgQDfYBY3FxSPmmAPRSiI-RmFG8zsVyQXjiTmXYtoCYXOmJno/s320/CheckClientUpdates-%25E5%2581%25B5%25E6%25B8%25AC%25E5%2587%25BA%25E4%25B8%258D%25E6%2594%25AF%25E6%258F%25B4TLS1.2.png" width="320" /></a></div></b></div><b><br /> </b></div><div class="separator" style="clear: both; text-align: left;"><b> </b></div><div class="separator" style="clear: both; text-align: left;"><b> </b></div><div class="separator" style="clear: both; text-align: left;"><b> </b></div><div class="separator" style="clear: both; text-align: left;"><b>以下文章參考用,和升級TLS 1.2無關</b><br /></div><div class="separator" style="clear: both; text-align: left;"><a href="https://docs.microsoft.com/en-us/sql/connect/oledb/oledb-driver-for-sql-server?view=sql-server-ver15">https://docs.microsoft.com/en-us/sql/connect/oledb/oledb-driver-for-sql-server?view=sql-server-ver15<br /></a><h2 class="heading-anchor" id="different-generations-of-ole-db-drivers" style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: inherit; color: #171717; font-family: "Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 2.125rem; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 600; letter-spacing: normal; line-height: 1.3; margin: 32px 0px 12px -1.875rem; orphans: 2; outline-color: inherit; padding: 0px 0px 0px 1.875rem; position: relative; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">Different generations of OLE DB Drivers</h2><p style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: inherit; color: #171717; font-family: "Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; margin: 1rem 0px 0px; orphans: 2; outline-color: inherit; overflow-wrap: break-word; padding: 0px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">There are three distinct generations of Microsoft OLE DB providers for SQL Server.</p><h3 class="heading-anchor" id="1-microsoft-ole-db-provider-for-sql-server-sqloledb" style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: inherit; color: #171717; font-family: "Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 1.75rem; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 600; letter-spacing: normal; line-height: 1.3; margin: 30px 0px 18px -1.875rem; orphans: 2; outline-color: inherit; padding: 0px 0px 0px 1.875rem; position: relative; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">1. Microsoft OLE DB Provider for SQL Server (SQLOLEDB)</h3><p style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: inherit; color: #171717; font-family: "Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; margin: 1rem 0px 0px; orphans: 2; outline-color: inherit; overflow-wrap: break-word; padding: 0px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">The<span> </span><a data-linktype="relative-path" href="https://docs.microsoft.com/en-us/sql/ado/guide/appendixes/microsoft-ole-db-provider-for-sql-server?view=sql-server-ver15" style="background-color: transparent; box-sizing: inherit; color: var(--theme-hyperlink); cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration: none;">Microsoft OLE DB Provider for SQL Server</a><span> </span>(SQLOLEDB) still ships as part of<span> </span><a data-linktype="absolute-path" href="https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ms692897(v=vs.85)" style="background-color: transparent; box-sizing: inherit; color: var(--theme-hyperlink); cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration: none;">Windows Data Access Components</a>. It is not maintained anymore and it is not recommended to use this driver for new development.</p><h3 class="heading-anchor" id="2-sql-server-native-client-snac" style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: inherit; color: #171717; font-family: "Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 1.75rem; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 600; letter-spacing: normal; line-height: 1.3; margin: 30px 0px 18px -1.875rem; orphans: 2; outline-color: inherit; padding: 0px 0px 0px 1.875rem; position: relative; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">2. SQL Server Native Client (SNAC)</h3><p style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: inherit; color: #171717; font-family: "Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; margin: 1rem 0px 0px; orphans: 2; outline-color: inherit; overflow-wrap: break-word; padding: 0px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">Starting in SQL Server 2005 (9.x), the<span> </span><a data-linktype="relative-path" href="https://docs.microsoft.com/en-us/sql/relational-databases/native-client/sql-server-native-client?view=sql-server-ver15" style="background-color: transparent; box-sizing: inherit; color: var(--theme-hyperlink); cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration: none;">SQL Server Native Client (SNAC)</a><span> </span>includes an OLE DB provider interface (SQLNCLI) and <b>is the OLE DB provider that shipped with SQL Server 2005 (9.x) through SQL Server 2012 (11.x)</b>.</p><p style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: inherit; color: #171717; font-family: "Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; margin: 1rem 0px 0px; orphans: 2; outline-color: inherit; overflow-wrap: break-word; padding: 0px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">It was<span> </span><a data-linktype="absolute-path" href="https://docs.microsoft.com/en-us/archive/blogs/sqlnativeclient/microsoft-is-aligning-with-odbc-for-native-relational-data-access" style="background-color: transparent; box-sizing: inherit; color: var(--theme-hyperlink); cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration: none;">announced as deprecated in 2011</a><span> </span>and it is not recommended to use this driver for new development. For more information about the SNAC lifecycle and available downloads, refer to<span> </span><a data-linktype="absolute-path" href="https://docs.microsoft.com/en-us/archive/blogs/sqlreleaseservices/snac-lifecycle-explained" style="background-color: transparent; box-sizing: inherit; color: var(--theme-hyperlink); cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration: none;">SNAC lifecycle explained</a>.</p><h3 class="heading-anchor" id="3-microsoft-ole-db-driver-for-sql-server-msoledbsql" style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: inherit; color: #171717; font-family: "Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 1.75rem; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 600; letter-spacing: normal; line-height: 1.3; margin: 30px 0px 18px -1.875rem; orphans: 2; outline-color: inherit; padding: 0px 0px 0px 1.875rem; position: relative; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">3. Microsoft OLE DB Driver for SQL Server (MSOLEDBSQL)</h3><p style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: inherit; color: #171717; font-family: "Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; margin: 1rem 0px 0px; orphans: 2; outline-color: inherit; overflow-wrap: break-word; padding: 0px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">OLE DB was<span> </span><a data-linktype="absolute-path" href="https://docs.microsoft.com/en-us/archive/blogs/sqlnativeclient/announcing-the-new-release-of-ole-db-driver-for-sql-server" style="background-color: transparent; box-sizing: inherit; color: var(--theme-hyperlink); cursor: pointer; outline-color: inherit; outline-style: initial; outline-width: 0px; overflow-wrap: break-word; text-decoration: none;">undeprecated</a><span> </span>and released in 2018.</p><p style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: inherit; color: #171717; font-family: "Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; margin: 1rem 0px 0px; orphans: 2; outline-color: inherit; overflow-wrap: break-word; padding: 0px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">The new OLE DB provider is called the Microsoft OLE DB Driver for SQL Server (MSOLEDBSQL). The new provider will be updated with the most recent server features going forward.</p><div class="alert is-info" style="-webkit-text-stroke-width: 0px; background-color: var(--theme-info-background); border-radius: 6px; border: 1px solid var(--theme-info-background-glow-high-contrast); box-sizing: inherit; color: #171717; display: block; font-family: "Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; margin-top: 1rem; orphans: 2; outline-color: var(--theme-text); overflow-wrap: break-word; padding: 1rem; position: relative; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; transition: height 0.5s ease-in 0s, opacity 0.5s ease-in 0s; white-space: normal; widows: 2; word-break: break-word; word-spacing: 0px;"><p class="alert-title" style="box-sizing: inherit; color: var(--theme-info-dark); font-weight: 600; margin: 0px; max-width: 100%; outline-color: inherit; overflow-wrap: break-word; padding: 0px;"><span aria-hidden="true" class="docon docon-status-error-outline" style="-webkit-font-smoothing: antialiased; box-sizing: inherit; direction: ltr; display: inline-block; font-family: docons; font-size: inherit; font-style: normal; font-variant: normal; font-weight: 400; line-height: 16px; outline-color: inherit; speak: none; text-align: center; text-transform: none;"></span><span> </span>Note</p><p style="box-sizing: inherit; margin: 1rem 0px 0px; max-width: 100%; outline-color: inherit; overflow-wrap: break-word; padding: 0px;">To use the new Microsoft OLE DB Driver for SQL Server in existing applications, you should plan to convert your connection strings from SQLOLEDB or SQLNCLI, to MSOLEDBSQL.</p></div></div><div class="separator" style="clear: both; text-align: left;"> </div><br />Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-74726889515655582362021-08-28T22:45:00.005+08:002021-08-28T22:51:07.527+08:00KB 4486153:Windows 10和 Windows Server 2019的.NET Framework 4.8<p><span style="font-size: small;"><a href="https://support.microsoft.com/zh-tw/topic/%E9%81%A9%E7%94%A8%E6%96%BC-x64-%E6%9B%B4%E6%96%B0%E4%B9%8B-windows-server-2019-windows-10-1709-%E7%89%88%E5%92%8C-windows-10-1803-%E7%89%88%E5%92%8C-windows-10-1809-%E7%89%88%E7%9A%84-microsoft-net-framework-4-8-9e61c44e-08d2-f20d-c890-9ed873d9dba0">https://support.microsoft.com/zh-tw/topic/%E9%81%A9%E7%94%A8%E6%96%BC-x64-%E6%9B%B4%E6%96%B0%E4%B9%8B-windows-server-2019-windows-10-1709-%E7%89%88%E5%92%8C-windows-10-1803-%E7%89%88%E5%92%8C-windows-10-1809-%E7%89%88%E7%9A%84-microsoft-net-framework-4-8-9e61c44e-08d2-f20d-c890-9ed873d9dba0</a></span></p><p><span style="font-size: small;"> </span><span style="font-size: small;">簡介</span></p><p style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; color: #1e1e1e; font-family: "Segoe UI", "Segoe UI Web", wf_segoe-ui_normal, "Helvetica Neue", "BBAlpha Sans", "S60 Sans", Arial, sans-serif; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 1.5; padding: 0px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="font-size: small;">本文介紹了 Windows 10、版本 1709、Windows 10、版本 1803、Windows Server、版本 1803、Windows 10、版本 1809 和 Windows Server、版本 1809 和 Windows Server 2019 上的 Microsoft .NET Framework 4.8 的更新。</span></p><p style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; color: #1e1e1e; font-family: "Segoe UI", "Segoe UI Web", wf_segoe-ui_normal, "Helvetica Neue", "BBAlpha Sans", "S60 Sans", Arial, sans-serif; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 1.5; padding: 0px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="font-size: small;">請注意: 從 2020 年 1 月 14 日開始,.NET Framework 4.8 已使用最新的服務更新重新整理。<a class="ocpExternalLink" href="https://devblogs.microsoft.com/dotnet/net-framework-january-security-and-quality-rollup" style="box-sizing: border-box; color: #006cb4; text-decoration: none;" target="_blank"><span> </span></a>除了 服務修正程式,2019 年 8 月 13 日發行的 Windows Update 中 , .NET Framework 4.8 產品中沒有任何變更。 如果您已下載並 安裝 8 月發行的更新,則不需要安裝此更新, 否則,請安裝此更新以收到最新的產品位元。</span></p><p style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; color: #1e1e1e; font-family: "Segoe UI", "Segoe UI Web", wf_segoe-ui_normal, "Helvetica Neue", "BBAlpha Sans", "S60 Sans", Arial, sans-serif; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 1.5; padding: 0px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span style="font-size: small;"> </span></p><p style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; color: #1e1e1e; font-family: "Segoe UI", "Segoe UI Web", wf_segoe-ui_normal, "Helvetica Neue", "BBAlpha Sans", "S60 Sans", Arial, sans-serif; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 1.5; padding: 0px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-decoration-thickness: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><a href="https://support.microsoft.com/zh-tw/topic/%E7%94%A8%E6%96%BC-windows-%E7%9A%84-microsoft-net-framework-4-8-%E9%9B%A2%E7%B7%9A%E5%AE%89%E8%A3%9D%E7%A8%8B%E5%BC%8F-9d23f658-3b97-68ab-d013-aa3c3e7495e0"><span style="font-size: small;">https://support.microsoft.com/zh-tw/topic/%E7%94%A8%E6%96%BC-windows-%E7%9A%84-microsoft-net-framework-4-8-%E9%9B%A2%E7%B7%9A%E5%AE%89%E8%A3%9D%E7%A8%8B%E5%BC%8F-9d23f658-3b97-68ab-d013-aa3c3e7495e0</span></a></p><p class="x-hidden-focus">安裝此套件時,將根據您的作業系統安装以下套件或更新:</p>
<ul><li>
<p>在 Windows 7 SP1 和 Windows Server 2008 R2 SP1 中,Microsoft.NET Framework 4.8.1 (KB4503548) 在「控制台」下的「程式和功能」中列為已安裝產品。</p>
</li><li>
<p>在 Windows Server 2012 中,Microsoft Windows 的更新
(KB4486081) 位於控制台下的「已安裝更新」中。 在 Windows 8.1 或 Windows Server 2012 R2
中,Microsoft Windows 的更新 (KB4486105) 位於控制台的「已安装更新」當中。</p>
</li><li>
<p>在 Windows 8.1 或 Windows Server 2012 R2 中,Microsoft Windows 的更新 (KB4486105) 位於控制台的「已安装更新」當中。</p>
</li><li>
<p>在 Windows 10 周年更新(版本 1607)、Windows 10 建立者更新 (版本 1703) 和
Windows Sever 2016 中,它在控制台下的「已安裝更新」中被列為 Microsoft Windows 更新
(KB4486129)。</p>
</li><li>
<p class="x-hidden-focus">在 Windows 10 秋季建立者的更新版本
1709、Windows 2018 年 4 月 10 日更新 (版本 1803)、Windows 2018 2018 更新 (版本 1809) 和
Windows Server 2019 中,它在控制台的「已安裝更新」下被列為「微軟 Windows 更新 」(KB4486153)。</p>
</li></ul>Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-87361401663436427642020-06-22T01:42:00.002+08:002020-06-22T01:43:45.243+08:00開發NET Framework 4.8最低需要Visual Studio 2012VS2010裝了NET Framework 4.8 developer pack也無法開發,最低需要VS2012Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-17997243111787895792020-06-21T16:50:00.001+08:002020-06-22T01:40:52.768+08:00製作Visual Studio 2019專業版離線安裝檔因為<a href="https://social.msdn.microsoft.com/Forums/zh-TW/05dc70ba-7d82-4d1d-8fc4-29ad313f9d30/visual-studio-community-2017-license-23433350372183938988?forum=230">公司屬於企業組織</a>,根據<a href="https://visualstudio.microsoft.com/zh-hant/license-terms/mlt031819/">授權條款</a>不能在公司使用Community版本,但公司連網際網路有管制,需要製作離線安裝檔。<br />
<br />
事先到<a href="https://docs.microsoft.com/zh-tw/visualstudio/install/create-an-offline-installation-of-visual-studio?view=vs-2019">https://docs.microsoft.com/zh-tw/visualstudio/install/create-an-offline-installation-of-visual-studio?view=vs-2019</a>下載vs_professional.exe<br />
<br />
離線安裝檔包含.NET web和.NET desktop development和Office development(繁中和英文):<br />
請事先在D磁碟機建立vs2019pro資料夾<br />
使用命令提示字元執行以下指令<br />
vs_professional.exe --layout D:\vs2019pro --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Component.GitHub.VisualStudio --add Microsoft.VisualStudio.Workload.Office --includeOptional --lang en-US zh-TW<br />
<br />
<br />
<br />
參考資料:<br />
<a href="https://docs.microsoft.com/zh-tw/visualstudio/install/create-an-offline-installation-of-visual-studio?view=vs-2019">https://docs.microsoft.com/zh-tw/visualstudio/install/create-an-offline-installation-of-visual-studio?view=vs-2019</a><br />
<br />
<a href="https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/install/create-an-offline-installation-of-visual-studio.md">https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/install/create-an-offline-installation-of-visual-studio.md</a><br />
<br />
<br />
<b>For .NET web and .NET desktop development, run:</b><br />
vs_professional.exe --layout D:\vs2019pro --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --add Component.GitHub.VisualStudio --includeOptional --lang en-US zh-TW<br />
<br />
<br />
<b>To create a complete local layout with all features (this will take a long time—we have lots of features!), run:</b><br />
vs_professional.exe --layout D:\vs2019pro --lang en-US zh-TW<br />
<br />
<br />
<b>For .NET desktop and Office development, run:</b><br />
vs_professional.exe --layout D:\vs2019pro --add Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.Office --includeOptional --lang en-US zh-TW<br />
<br />Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-16589810440654470692020-06-13T11:02:00.001+08:002020-06-13T11:03:41.844+08:00BinaryFormatter()搭配SerializationBinder類別驗證許可還原序列化的類別<span style="color: black;">避免Unsafe Deserialization弱點</span><br />
<span style="color: black;"><br /><br /><br /><a href="https://topic.alibabacloud.com/tc/a/-net-c--pilot-type-in-deserialization-using-serializationbinder_1_31_32345296.html">https://topic.alibabacloud.com/tc/a/-net-c--pilot-type-in-deserialization-using-serializationbinder_1_31_32345296.html</a></span><br />
<div data-spm-anchor-id="a2c61.500233.200003.i5.7e745b5eUrvtnQ" style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
//SerializationBinder的執行類</div>
<div data-spm-anchor-id="a2c61.500233.200003.i3.7e745b5eUrvtnQ" style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
class ConversionBinder : SerializationBinder</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
{</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
public override Type BindToType(string assemblyName, string typeName)</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
{</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
//篩選Person類型</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
//判斷是否是Person類型,如果是返回Person_ver2</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
var curAssName = typeof(Program).Assembly.FullName;</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
var person1 = typeof(Person).FullName;</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
string finalType = typeName;</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
if (assemblyName == curAssName && typeName == person1)</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
finalType = typeof(Person_ver2).FullName;</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
return Type.GetType(finalType + "," + assemblyName);</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
}</div>
<div data-spm-anchor-id="a2c61.500233.200003.i4.7e745b5eUrvtnQ" style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
}</div>
<br />
<div data-spm-anchor-id="a2c61.500233.200003.i2.7e745b5eUrvtnQ" style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
var bf = new BinaryFormatter();</div>
<div style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
//設定自訂的SerializationBinder對象</div>
<div data-spm-anchor-id="a2c61.500233.200003.i0.7e745b5eUrvtnQ" style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<b>bf.Binder = new ConversionBinder();</b></div>
<div data-spm-anchor-id="a2c61.500233.200003.i0.7e745b5eUrvtnQ" style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<div style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; color: #666666; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
//序列化Person</div>
<div data-spm-anchor-id="a2c61.500233.200003.i9.7e745b5eUrvtnQ" style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; color: #666666; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
bf.Serialize(ms, p1);</div>
</div>
<div data-spm-anchor-id="a2c61.500233.200003.i0.7e745b5eUrvtnQ" style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
ref:</div>
<div data-spm-anchor-id="a2c61.500233.200003.i0.7e745b5eUrvtnQ" style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; font-family: -apple-system, Roboto-Regular, Roboto, "Microsoft Yahei", "Helvetica Neue", Helvetica, Tahoma, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 21px; margin: 16px 0px 10px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<a href="https://media.blackhat.com/bh-us-12/Briefings/Forshaw/BH_US_12_Forshaw_Are_You_My_Type_WP.pdf">https://media.blackhat.com/bh-us-12/Briefings/Forshaw/BH_US_12_Forshaw_Are_You_My_Type_WP.pdf</a> <br />
p.13 </div>
<a href="https://www.slideshare.net/MSbluehat/dangerous-contents-securing-net-deserialization?from_action=save">https://www.slideshare.net/MSbluehat/dangerous-contents-securing-net-deserialization?from_action=save</a><br />
p.27<br />
<br />
<a href="https://owasp.org/www-community/vulnerabilities/Deserialization_of_untrusted_data">https://owasp.org/www-community/vulnerabilities/Deserialization_of_untrusted_data</a>Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-74253709574567759282020-06-07T22:51:00.003+08:002020-06-07T22:51:30.250+08:00ASP.NET Core Razor Pages – Handler Methods<a href="https://codingblast.com/asp-net-core-razor-pages-handlers/">https://codingblast.com/asp-net-core-razor-pages-handlers/</a><br />
<br />
<a href="https://www.cnblogs.com/tdfblog/p/razor-pages-handlers-in-asp-net-core.html">https://www.cnblogs.com/tdfblog/p/razor-pages-handlers-in-asp-net-core.html</a><br />
Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-19898784418731264342020-06-07T22:46:00.002+08:002020-06-07T22:46:12.809+08:00Author Tag Helpers in ASP.NET Core<a href="https://docs.microsoft.com/zh-tw/aspnet/core/mvc/views/tag-helpers/authoring?view=aspnetcore-3.1">https://docs.microsoft.com/zh-tw/aspnet/core/mvc/views/tag-helpers/authoring?view=aspnetcore-3.1</a>Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-29261237251577245442020-06-07T22:41:00.002+08:002020-06-07T22:41:53.504+08:00David Paquette分享的TagHelperSamples<a href="https://github.com/dpaquette/TagHelperSamples">https://github.com/dpaquette/TagHelperSamples</a>Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-49737071472714811752020-06-07T22:27:00.002+08:002020-06-07T22:42:14.726+08:00Authoring Tag Helpers<a href="https://aspnetcore.readthedocs.io/en/stable/mvc/views/tag-helpers/authoring.html">https://aspnetcore.readthedocs.io/en/stable/mvc/views/tag-helpers/authoring.html</a><br />
<br />Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-80402850409822805172020-06-07T22:13:00.002+08:002020-06-07T22:13:12.731+08:00Model Binding in Razor Pages <a href="https://www.learnrazorpages.com/razor-pages/model-binding">https://www.learnrazorpages.com/razor-pages/model-binding</a>Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-20946419648770222332020-06-04T00:04:00.001+08:002020-06-04T00:23:00.007+08:00NET Core 2.1開始Identity UI被包進Razor Class Library<div style="box-sizing: border-box; font-family: "Segoe UI", system-ui, "Apple Color Emoji", "Segoe UI Emoji", sans-serif; font-size: 14px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<div class="copy-paste-block">
NET Core 2.1開始<span style="font-size: 15px;">Identity UI被包進<span style="font-size: 15px;">Razor Class Library</span></span></div>
<div class="copy-paste-block">
如果需要<span style="font-size: 15px;">Identity Core的cshtml修改可以參考</span></div>
<div class="copy-paste-block">
<a href="https://stackoverflow.com/questions/50802781/where-are-the-login-and-register-pages-in-an-aspnet-core-scaffolded-app" rel="noreferrer noopener" tabindex="-1" target="_blank" title="https://stackoverflow.com/questions/50802781/where-are-the-login-and-register-pages-in-an-aspnet-core-scaffolded-app">https://stackoverflow.com/questions/50802781/where-are-the-login-and-register-pages-in-an-aspnet-core-scaffolded-app</a><br />
<br />
</div>
<div class="copy-paste-block">
</div>
<div class="copy-paste-block">
<b>指令產生</b></div>
<div class="copy-paste-block">
<a href="https://docs.microsoft.com/zh-tw/aspnet/core/fundamentals/tools/dotnet-aspnet-codegenerator?view=aspnetcore-3.1">https://docs.microsoft.com/zh-tw/aspnet/core/fundamentals/tools/dotnet-aspnet-codegenerator?view=aspnetcore-3.1</a> </div>
<div class="copy-paste-block">
先安裝ASP.NET Core scaffolding engine</div>
<div class="copy-paste-block">
指令dotnet tool install -g dotnet-aspnet-codegenerator</div>
<div class="copy-paste-block">
<br /></div>
<div class="copy-paste-block">
<a href="https://devblogs.microsoft.com/aspnet/aspnetcore-2-1-identity-ui/">https://devblogs.microsoft.com/aspnet/aspnetcore-2-1-identity-ui/</a> </div>
<div class="copy-paste-block">
指令dotnet aspnet-codegenerator identity </div>
<div class="copy-paste-block">
需要先用NuGet安裝以下套件(用Visual Studio的Scaffolding Item會自動安裝)</div>
<div class="copy-paste-block">
Microsoft.VisualStudio.Web.CodeGeneration.Design </div>
<div class="copy-paste-block">
Microsoft.AspNetCore.Identity.UI</div>
<div class="copy-paste-block">
Microsoft.EntityFrameworkCore.Design</div>
<div class="copy-paste-block">
Microsoft.EntityFrameworkCore.SqlServer</div>
</div>
Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-72094306337995219572020-06-03T22:02:00.001+08:002020-06-03T22:02:27.268+08:00error CS0234: 命名空間 'Microsoft.AspNetCore.Identity' 中沒有類型或命名空間名稱 'UI' (是否遺漏了組件參考?) 因為Microsoft.AspNetCore.Identity.UI 3.1.4 只支援.NET Core 3.1以上<br />
<a href="https://www.nuget.org/packages/Microsoft.AspNetCore.Identity.UI">https://www.nuget.org/packages/Microsoft.AspNetCore.Identity.UI</a><br />
所以要把專案升級到.NET Core 3.1以上<br />
<br />
<br />
obj\Debug\netcoreapp3.0\SkillTreeRazorPageBlogSample.AssemblyInfo.cs(14,42): error CS0234: 命名空間 'Microsoft.AspNetCore.Identity' 中沒有類型或命名空間名稱 'UI' (是否遺漏了組件參考?) [D:\temptest\SkillTreeRazorPageBlogSample.csproj]<br /> 0 個警告<br /> 1 個錯誤<br /><br />經過時間 00:00:03.72<br />RunTime 00:00:14.95Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-5209029952031455692020-06-01T22:49:00.001+08:002020-06-01T23:16:13.005+08:00TagMode.StartTagAndEndTag<a href="https://docs.microsoft.com/zh-tw/aspnet/core/mvc/views/tag-helpers/authoring?view=aspnetcore-3.1">https://docs.microsoft.com/zh-tw/aspnet/core/mvc/views/tag-helpers/authoring?view=aspnetcore-3.1</a><br />
<br />
<div style="-webkit-text-stroke-width: 0px; box-sizing: inherit; color: #171717; font-family: "Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; margin: 1rem 0px 0px; max-width: 100%; orphans: 2; outline-color: inherit; overflow-wrap: break-word; padding: 0px; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<span class="sxs-lookup" style="box-sizing: inherit; display: inline; outline-color: inherit;"><span data-stu-id="ec8ab-214" style="box-sizing: inherit; outline-color: inherit;">You can use the following markup with a closing tag and remove the line with <code style="background-color: var(--body-background-dark); border-radius: 3px; box-sizing: inherit; direction: ltr; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 13.6px; outline-color: inherit; overflow-wrap: break-word; padding: 0.1em 0.2em;">TagMode.StartTagAndEndTag</code> in the tag helper:</span></span></div>
<pre class="has-inner-focus" style="-webkit-font-smoothing: auto; -webkit-text-stroke-width: 0px; background-color: var(--body-background-medium); border: 1px solid var(--border); box-sizing: inherit; color: #171717; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace !important; font-size: 0.875rem; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; hyphens: none; letter-spacing: normal; line-height: 19px; margin: 0px; max-width: 100%; orphans: 2; outline: none; overflow-wrap: normal; overflow: auto; padding: 1rem; tab-size: 4; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-break: normal; word-spacing: 0px;" tabindex="0"><code class="lang-html" data-author-content="<website-information info="webContext" >
</website-information>
" style="border: 0px; box-sizing: inherit; direction: ltr; display: block; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 1em; line-height: 19px; outline-color: inherit; padding: 0px; position: relative;"><span style="box-sizing: inherit; outline-color: inherit;"><span class="hljs-tag" style="box-sizing: inherit; color: #0101fd; outline-color: inherit;"><<span class="hljs-name" style="box-sizing: inherit; color: #0101fd; outline-color: inherit;">website-information</span> <span class="hljs-attr" style="box-sizing: inherit; color: #0451a5; outline-color: inherit;">info</span>=<span class="hljs-string" style="box-sizing: inherit; color: #a31515; outline-color: inherit;">"webContext"</span> ></span>
<span class="hljs-tag" style="box-sizing: inherit; color: #0101fd; outline-color: inherit;"></<span class="hljs-name" style="box-sizing: inherit; color: #0101fd; outline-color: inherit;">website-information</span>></span></span></code></pre>
<div style="-webkit-text-stroke-width: 0px; box-sizing: inherit; color: #171717; font-family: "Segoe UI", SegoeUI, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; margin: 1rem 0px 0px; max-width: 100%; orphans: 2; outline-color: inherit; overflow-wrap: break-word; padding: 0px; text-align: left; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
<code class="lang-html" data-author-content="<website-information info="webContext" >
</website-information>
" style="border: 0px; box-sizing: inherit; direction: ltr; display: block; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 1em; line-height: 19px; outline-color: inherit; padding: 0px; position: relative;"><span style="box-sizing: inherit; outline-color: inherit;"><span class="hljs-tag" style="box-sizing: inherit; color: #0101fd; outline-color: inherit;"><br /></span></span></code><code class="lang-html" data-author-content="<website-information info="webContext" >
</website-information>
" style="border: 0px; box-sizing: inherit; direction: ltr; display: block; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 1em; line-height: 19px; outline-color: inherit; padding: 0px; position: relative;"><span style="box-sizing: inherit; outline-color: inherit;"><span class="hljs-tag" style="box-sizing: inherit; color: #0101fd; outline-color: inherit;"><br /></span></span></code><br /><code class="lang-html" data-author-content="<website-information info="webContext" >
</website-information>
" style="border: 0px; box-sizing: inherit; direction: ltr; display: block; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 1em; line-height: 19px; outline-color: inherit; padding: 0px; position: relative;"><span style="box-sizing: inherit; outline-color: inherit;"><span class="hljs-tag" style="box-sizing: inherit; color: #0101fd; outline-color: inherit;"><a href="https://whosnailaspnetcoredocs.readthedocs.io/ko/latest/mvc/views/tag-helpers/authoring.html">https://whosnailaspnetcoredocs.readthedocs.io/ko/latest/mvc/views/tag-helpers/authoring.html</a></span></span></code><br />
<pre style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; color: #404040; display: block; font-family: Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace; font-size: 12px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: normal; margin: 0px; orphans: 2; overflow: auto; padding: 12px; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: pre; widows: 2; word-spacing: 0px;"><span class="hll" style="box-sizing: border-box; display: block; margin: 0px -12px; padding: 0px 12px;"><span class="na" style="box-sizing: border-box;">[HtmlTargetElement("email", TagStructure = TagStructure.WithoutEndTag)]</span>
</span><span class="k" style="box-sizing: border-box;">public</span> <span class="k" style="box-sizing: border-box;">class</span> <span class="nc" style="box-sizing: border-box;">EmailVoidTagHelper</span> <span class="p" style="box-sizing: border-box;">:</span> <span class="n" style="box-sizing: border-box;">TagHelper</span>
<span class="p" style="box-sizing: border-box;">{</span>
<span class="k" style="box-sizing: border-box;">private</span> <span class="k" style="box-sizing: border-box;">const</span> <span class="kt" style="box-sizing: border-box;">string</span> <span class="n" style="box-sizing: border-box;">EmailDomain</span> <span class="p" style="box-sizing: border-box;">=</span> <span class="s" style="box-sizing: border-box;">"contoso.com"</span><span class="p" style="box-sizing: border-box;">;</span>
<span class="c1" style="box-sizing: border-box;">// Code removed for brevity</span></pre>
<code class="lang-html" data-author-content="<website-information info="webContext" >
</website-information>
" style="border: 0px; box-sizing: inherit; direction: ltr; display: block; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 1em; line-height: 19px; outline-color: inherit; padding: 0px; position: relative;"><span style="box-sizing: inherit; outline-color: inherit;"><span class="hljs-tag" style="box-sizing: inherit; color: #0101fd; outline-color: inherit;"> </span></span></code><code class="lang-html" data-author-content="<website-information info="webContext" >
</website-information>
" style="border: 0px; box-sizing: inherit; direction: ltr; display: block; font-family: SFMono-Regular, Consolas, "Liberation Mono", Menlo, Courier, monospace; font-size: 1em; line-height: 19px; outline-color: inherit; padding: 0px; position: relative;"><span style="box-sizing: inherit; outline-color: inherit;"><span class="hljs-tag" style="box-sizing: inherit; color: #0101fd; outline-color: inherit;"> </span></span></code></div>
ref:<br />
<a href="https://www.cnblogs.com/dotNETCoreSG/p/aspnetcore-4_3_6_2-tag-helpers-authoring.html">https://www.cnblogs.com/dotNETCoreSG/p/aspnetcore-4_3_6_2-tag-helpers-authoring.html</a> Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-34312523837578608102020-05-31T19:15:00.001+08:002020-05-31T19:16:20.426+08:00AddDefaultIdentity已在 ASP.NET Core 2.1 中引進<a href="https://docs.microsoft.com/zh-tw/aspnet/core/security/authentication/identity?view=aspnetcore-3.1&tabs=visual-studio#adddefaultidentity-and-addidentity">https://docs.microsoft.com/zh-tw/aspnet/core/security/authentication/identity?view=aspnetcore-3.1&tabs=visual-studio#adddefaultidentity-and-addidentity</a><br />
AddDefaultIdentity已在 ASP.NET Core 2.1 中引進。 呼叫AddDefaultIdentity類似于呼叫下列內容:AddIdentity、AddDefaultUI、AddDefaultTokenProviders<br />
<br />
原始碼<br />
<a href="https://github.com/aspnet/Identity/blob/c7276ce2f76312ddd7fccad6e399da96b9f6fae1/src/UI/IdentityServiceCollectionUIExtensions.cs#L49">https://github.com/aspnet/Identity/blob/c7276ce2f76312ddd7fccad6e399da96b9f6fae1/src/UI/IdentityServiceCollectionUIExtensions.cs#L49</a><br />
<br />
ref:<br />
<a href="https://docs.microsoft.com/zh-tw/aspnet/core/security/authorization/secure-data?view=aspnetcore-3.1">https://docs.microsoft.com/zh-tw/aspnet/core/security/authorization/secure-data?view=aspnetcore-3.1</a>Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-53250925779905013312020-05-23T15:23:00.001+08:002020-05-23T16:06:41.126+08:00libphonenumber-csharp<a href="https://github.com/twcclegg/libphonenumber-csharp">https://github.com/twcclegg/libphonenumber-csharp</a><br />
<br />檢查電話號碼格式是否正確<br />還會顯示分類:FIXED_LINE、MOBILE、VOIP(070門號)、TOLL_FREE(080門號) <br /><br />DEMO: <br /><a href="https://libphonenumber.appspot.com/">https://libphonenumber.appspot.com</a><br /><br />
Java原版:<br />
<a href="https://github.com/google/libphonenumber">https://github.com/google/libphonenumber</a><br />
<br />
ref:<br />
<a href="https://www.twilio.com/blog/validating-phone-numbers-effectively-with-c-and-the-net-frameworks">https://www.twilio.com/blog/validating-phone-numbers-effectively-with-c-and-the-net-frameworks</a><br />
<br />
<a href="https://medium.com/frochu/libphonenumber-example-app-f60680faa599">https://medium.com/frochu/libphonenumber-example-app-f60680faa599</a> Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-51053700576493918192020-05-23T14:05:00.000+08:002020-05-23T14:05:40.702+08:00InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Mvc.Infrastructure.IActionContextAccessor' while attempting to activate 寫.NET Core遇到Unable to resolve service for type通常是忘記註冊物件給DI容器<br />
<br />
Startup.cs的ConfigureServices(IServiceCollection services)加入以下這一行<br />
//TagsHelper使用<br />
services.AddSingleton<IActionContextAccessor, ActionContextAccessor>();<br />
<br />
<br />
錯誤訊息:<br />
InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Mvc.Infrastructure.IActionContextAccessor' while attempting to activate Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-71268747707483103422020-05-23T13:56:00.002+08:002020-05-23T13:56:42.807+08:00IList和IEnumerable的比較自己通常使用IEnumerable<T><br />
但還是會有需要用到IList<T>的時候 <br />
<br />
<a href="http://trufflepenne.blogspot.com/2013/04/ilistienumerable.html">http://trufflepenne.blogspot.com/2013/04/ilistienumerable.html</a><br />
<br />
<a href="https://stackoverflow.com/questions/376708/ilist-vs-ienumerable-for-collections-on-entities">https://stackoverflow.com/questions/376708/ilist-vs-ienumerable-for-collections-on-entities</a><br />
<br />Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-56663035974197282962020-02-09T11:57:00.000+08:002020-02-09T18:08:57.461+08:00C#和Java的泛型差異<a href="http://www.jprl.com/Blog/archive/development/2007/Aug-31.html">http://www.jprl.com/Blog/archive/development/2007/Aug-31.html</a><br />雖然很舊的文章,但是很詳細的比較了C#和Java泛型的差異<br /><br />最近在看<a href="https://www.amazon.com/Essential-6-0-Addison-Wesley-Microsoft-Technology/dp/0134141040">Essential C# 6</a>這本書,第11章(C# 7是在第12章)有提到Java和C#泛型機制的不同。搜尋了一些資料,小弟我大致整理如下,歡迎先進補充指正,謝謝<br /><br />JDK 5加入泛型,為了避免修改JVM規格影響向下相容,是在編譯器實作泛型(不是在JVM實作),另外Java的泛型不支援Primitive Type(等同C#的Value Type)<br />Java採用Code Sharing實作,對每一個泛型類或泛型方法只會生成一份object code(byte code),Java compiler透過type erasure實作,也導致無法在runtime時期取得泛型類或泛型方法的實際型別<br />C#和C++ Template採用Code Specialization實作,對每一個泛型類或泛型方法都會產生一份object code<br />C# 2.0加入泛型,.NET是在CLI(common language implementation)加入泛型支援,性能較好,且可以在runtime時期取得泛型類或泛型方法的實際型別資訊<br /><br />參考資料:<br />Java魔法堂:解讀基於Type Erasure的泛型<br /><a href="https://www.cnblogs.com/fsjohnhuang/p/4288614.html">https://www.cnblogs.com/fsjohnhuang/p/4288614.html</a><br /><br />聊聊Java泛型類型擦除及Flink類型暗示(type hint)機制<br /><a href="https://www.jianshu.com/p/cfb8c1386f69">https://www.jianshu.com/p/cfb8c1386f69</a><br /><br />Type Erasure<br /><a href="https://docs.oracle.com/javase/tutorial/java/generics/erasure.html">https://docs.oracle.com/javase/tutorial/java/generics/erasure.html</a><br /><br /><a href="https://stackoverflow.com/questions/355060/c-sharp-vs-java-generics">https://stackoverflow.com/questions/355060/c-sharp-vs-java-generics</a><br /><br /><a href="https://stackoverflow.com/questions/31693/what-are-the-differences-between-generics-in-c-sharp-and-java-and-templates-i">https://stackoverflow.com/questions/31693/what-are-the-differences-between-generics-in-c-sharp-and-java-and-templates-i</a><br /><br />C# vs Java : Generics<br /><a href="http://toddgerspacher.blogspot.com/2017/07/c-vs-java-generics.html">http://toddgerspacher.blogspot.com/2017/07/c-vs-java-generics.html</a><br /><br />Generics in Java<br /><a href="https://en.wikipedia.org/wiki/Generics_in_Java#Problems_with_type_erasure">https://en.wikipedia.org/wiki/Generics_in_Java#Problems_with_type_erasure</a><br /><br />Generics in the Run Time (C# Programming Guide)<br /><a href="https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/generics-in-the-run-time">https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/generics/generics-in-the-run-time</a><br /><br />.NET Column: Introducing Generics in the CLR<br /><a href="https://docs.microsoft.com/en-us/archive/msdn-magazine/2003/september/net-column-introducing-generics-in-the-clr">https://docs.microsoft.com/en-us/archive/msdn-magazine/2003/september/net-column-introducing-generics-in-the-clr</a><br />Finally, the research group at Microsoft has modified a version of the shared source common language implementation (CLI), code-named "Rotor," to include generics support.<br /><br /><a href="https://dotnetfiddle.net/MEK7FM">https://dotnetfiddle.net/MEK7FM</a><br /><br /><br /><br />Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-17573539425027289482020-02-04T23:50:00.001+08:002020-02-04T23:51:43.679+08:00checked 關鍵字<br />
範例<br />
<a href="https://dotnetfiddle.net/Ubmgeg">https://dotnetfiddle.net/Ubmgeg</a><br />
<br />
REF:<br />
<a href="https://docs.microsoft.com/zh-tw/dotnet/csharp/language-reference/keywords/checked">https://docs.microsoft.com/zh-tw/dotnet/csharp/language-reference/keywords/checked</a><br />
<a href="https://dotblogs.com.tw/yc421206/2012/10/15/77489">https://dotblogs.com.tw/yc421206/2012/10/15/77489</a> Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-20275093809708592672020-02-02T11:23:00.004+08:002020-02-02T11:30:43.837+08:00reference types(參考型別)在哪種狀況下不同變數會被彼此影響?微軟官網文件<br />
『With reference types, it is possible for two variables to reference the same object and thus possible for operations on one variable to affect the object referenced by the other variable』<br />
<a href="https://docs.microsoft.com/en-us/dotnet/csharp/tour-of-csharp/types-and-variables">https://docs.microsoft.com/en-us/dotnet/csharp/tour-of-csharp/types-and-variables</a><br />
做了一個比較<br />
Java也有同樣的特性,Java叫做Primitive Type (基本型態)、Class Type / Reference Type (類別型態 / 參考型態)<br />
但是Java沒有struct類型(型別)<br />
<br />
使用reference types(變數會被彼此影響)<br />
<a href="https://dotnetfiddle.net/zURcCT">https://dotnetfiddle.net/zURcCT</a><br />
<br />
<br />
使用value types(變數不會被彼此影響)<br />
<a href="https://dotnetfiddle.net/nNaCPE">https://dotnetfiddle.net/nNaCPE </a><br />
<br />
<br />
自己整理的C#和Java比較<br /><a href="https://hackmd.io/SVIGNsLLRkqYxywgJpcgTg">https://hackmd.io/SVIGNsLLRkqYxywgJpcgTg</a><br />
<br />
Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-37964747378424459012020-01-01T12:47:00.002+08:002020-01-01T12:47:34.796+08:00How do you change the name of the ASP core 2 tempdata cookie name?<a href="https://www.codeproject.com/Questions/1229836/How-do-you-change-the-name-of-the-ASP-core-tempdat">https://www.codeproject.com/Questions/1229836/How-do-you-change-the-name-of-the-ASP-core-tempdat</a>Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-44219444984866438372020-01-01T12:29:00.000+08:002020-01-01T13:00:31.355+08:00MVC的TempData 則是可雙向交換的資料,ViewData 是單向丟給 View 的資料<a href="https://dotblogs.com.tw/regionbbs/2012/01/19/asp_net_mvc_view_object_differences">https://dotblogs.com.tw/regionbbs/2012/01/19/asp_net_mvc_view_object_differences</a><br />
<br />
ViewData 和 TempData 是在 MVC 中暫存資料的一種物件,和 Web Form 的 ViewState 很像<br />
<br />
所以,ViewData 是單向丟給 View 的資料,而 TempData 則是可雙向交換的資料,將 TempData 視為 Session,就可以更明白它的用處了。<br />
<br />
<br />
<a href="https://ithelp.ithome.com.tw/articles/10219477">https://ithelp.ithome.com.tw/articles/10219477</a> <br />
SessionStateTempDataProvider 控制儲存TempData <br />
<br />
<div style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; color: #303233; font-family: Lato, "PingFang TC", "Helvetica Neue", Helvetica, 微軟正黑體, 新細明體, Arial, sans-serif; font-size: 18px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 1.7; margin: 0px 0px 26px; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
上面說到<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px;">TempData</code>字典集合生命週期除了當下請求, 導頁後仍可續存.原因是在<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px;">SessionStateTempDataProvider</code>將資料存在<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px;">Session</code>中</div>
<pre style="-webkit-text-stroke-width: 0px; background-color: #232323; border-radius: 4px; border: none; box-sizing: border-box; color: #c4c4c4; display: block; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 15px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 1.42857; margin: 0px 0px 26px; orphans: 2; overflow-wrap: break-word; overflow: auto; padding: 16px; tab-size: 4; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; widows: 2; word-break: break-all; word-spacing: 0px;"><code class="language-csharp hljs" style="background: rgb(35, 35, 35); border-radius: 0px; box-sizing: border-box; color: #e6e1dc; display: block; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: inherit; overflow-x: auto; padding: 0.5em; white-space: pre-wrap;">controllerContext.HttpContext.Session[<span class="hljs-string" style="box-sizing: border-box; color: #a5c261;">"__ControllerTempData"</span>]
</code></pre>
<div style="-webkit-text-stroke-width: 0px; background-color: white; box-sizing: border-box; color: #303233; font-family: Lato, "PingFang TC", "Helvetica Neue", Helvetica, 微軟正黑體, 新細明體, Arial, sans-serif; font-size: 18px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 1.7; margin: 0px 0px 26px; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
可以透過上面程式碼取得當前的<code style="background-color: #f9f2f4; border-radius: 4px; box-sizing: border-box; color: #c7254e; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 16.2px; padding: 2px 4px;">TempData</code>字典集合物件.</div>
<a href="https://dotblogs.com.tw/wadehuang36/2010/10/02/tempdata">https://dotblogs.com.tw/wadehuang36/2010/10/02/tempdata</a><br />
<br />
<div style="-webkit-text-stroke-width: 0px; background-color: whitesmoke; color: #555555; font-family: "Helvetica Neue", Helvetica, Arial, "Heiti TC", "Apple LiGothic Medium", 微軟正黑體, sans-serif; font-size: 15px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 22px; margin: 22px 0px; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
預設的TempDataProvider是<a href="http://msdn.microsoft.com/zh-tw/library/system.web.mvc.sessionstatetempdataprovider.aspx" style="background-color: transparent; color: #187a00; overflow-wrap: break-word; text-decoration: none; transition: all 0.1s ease-in-out 0s; word-break: break-word;" target="_blank">SessionStateTempDataProvider</a>,你沒有看錯,預設是用Session來存放TempData,Session不是使用者存放資料,而且存留時間預設在20分鐘的嗎?</div>
<div style="-webkit-text-stroke-width: 0px; background-color: whitesmoke; color: #555555; font-family: "Helvetica Neue", Helvetica, Arial, "Heiti TC", "Apple LiGothic Medium", 微軟正黑體, sans-serif; font-size: 15px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; line-height: 22px; margin: 22px 0px; orphans: 2; text-align: start; text-decoration-color: initial; text-decoration-style: initial; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;">
所以SessionStateTempDataProvider有做一些手段,Controller起來時,從Session載入TempData,然後刪除Session,所以在Action時是不會看到TempData的Session,在讀取TempData時,會記錄用了那些Key,在Controller結束時,會把沒有過的TempData在存回Session中,所以一直<b style="font-weight: bolder;">沒有讀取的TempData是會存在到Session消失的</b>。</div>
原始碼:<br />
<a href="https://github.com/aspnet/AspNetWebStack/blob/master/src/System.Web.Mvc/SessionStateTempDataProvider.cs">https://github.com/aspnet/AspNetWebStack/blob/master/src/System.Web.Mvc/SessionStateTempDataProvider.cs</a><br />
<br />
<br />
關鍵字:<br />
ViewData、TempData、ViewDataDictionary、TempDataDictionary、ITempDataProvider、Session、SessionStateTempDataProvider、__ControllerTempData、TempDataSessionStateKey<br />
<span style="background-color: #333333; color: #bbbbbb; display: inline; float: none; font-family: "calisto mt"; font-size: small; font-style: normal; font-weight: 400; letter-spacing: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"></span> Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-44354358409330784022019-12-16T23:19:00.002+08:002019-12-16T23:19:28.197+08:00CefBrowser.SendProcessMessage Method<a href="https://xilium.bitbucket.io/cefglue/doc/html/E1D2718E.htm">https://xilium.bitbucket.io/cefglue/doc/html/E1D2718E.htm</a><br />
<br />
<br />
<a href="https://www.lagou.com/lgeduarticle/10063.html">https://www.lagou.com/lgeduarticle/10063.html</a><br />
<a href="https://www.blogger.com/null" name="process-runtime-messages" rel="nofollow" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-text-stroke-width: 0px; background-color: #fafafa; color: black; font-family: -apple-system-font, "Helvetica Neue", sans-serif; font-size: 12px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px; text-align: justify; text-decoration: none; text-indent: 0px; text-transform: none; touch-action: pan-y; white-space: normal; widows: 2; word-spacing: 0px;"></a><br />
<div style="-webkit-tap-highlight-color: transparent; font-size: 17px; margin: 0px; padding: 0px; touch-action: pan-y;">
<a href="https://www.blogger.com/null" name="process-runtime-messages" rel="nofollow" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0); -webkit-text-stroke-width: 0px; background-color: #fafafa; color: black; font-family: -apple-system-font, "Helvetica Neue", sans-serif; font-size: 12px; font-style: normal; font-variant-caps: normal; font-variant-ligatures: normal; font-weight: 400; letter-spacing: normal; margin: 0px; orphans: 2; padding: 0px; text-align: justify; text-decoration: none; text-indent: 0px; text-transform: none; touch-action: pan-y; white-space: normal; widows: 2; word-spacing: 0px;">在进程生命周期内,任何时候你都可以通过CefProcessMessage类传递进程间消息。这些信息和特定的CefBrowser实例绑定在一起,用户可以通过CefBrowser::SendProcessMessage()方法发送。进程间消息可以包含任意的状态信息,用户可以通过CefProcessMessage::GetArgumentList()获取。</a></div>
<br />Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0tag:blogger.com,1999:blog-8767575772750226242.post-53706305041042718662019-12-15T17:28:00.002+08:002019-12-15T17:28:38.731+08:00使用ChromiumFX 內嵌 Vue網頁<a href="https://www.cnblogs.com/FireworksEasyCool/p/11231912.html">https://www.cnblogs.com/FireworksEasyCool/p/11231912.html</a><br />
<b></b><i></i><u></u><sub></sub><sup></sup><strike></strike><br />
<br />
DEMO<br />
<a href="https://github.com/Bingjian-Zhu/ChromeiumFXDemo">https://github.com/Bingjian-Zhu/ChromeiumFXDemo</a><br />
<b></b><i></i><u></u><sub></sub><sup></sup><strike></strike><br />
官網<br />
<a href="https://bitbucket.org/chromiumfx/chromiumfx/">https://bitbucket.org/chromiumfx/chromiumfx/</a><b></b><i></i><u></u><sub></sub><sup></sup><strike></strike>Rexhttp://www.blogger.com/profile/10146109989474888540noreply@blogger.com0