วันพุธที่ 5 มิถุนายน พ.ศ. 2562

How To Migrate asp.net(under .net 4.5 ) website to TLS 1.2?


เมื่อมีการปิด TLS1.0
Error : The request was aborted: Could not create SSL/TLS secure channel.
ที่มา : https://github.com/navossoc/KeePass-Yet-Another-Favicon-Downloader/issues/23
สาเหตุ : อ่านเองนะ https://www.swoo.co.uk/blog/post/40135/how-to-migrate-a-net-website-to-tls-12

วิธีการแก้ไข ที่ง่ายได้ผล
Old Code : เดิมมีให้เลือกแค่นี้(VB.net)

// Only available from .Net 4.5+
 
// System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls12;

New Code : ตามนี้คับ
************************************************************
Dim _Tls12 As System.Security.Authentication.SslProtocols = CType(&HC00, System.Security.Authentication.SslProtocols)

Dim Tls12 As SecurityProtocolType = CType(_Tls12, SecurityProtocolType)
ServicePointManager.SecurityProtocol = Tls12
************************************************************

วิธีนี้ไม่ต้อง update .net Framework ได้ผลสำหรับผมนะ

วันพฤหัสบดีที่ 20 เมษายน พ.ศ. 2560

Install IIS on windows10

ไปที่ Control Panel\All Control Panel Items\Programs and Features























set Application Pools >> Enable 32-Bit Applications=True






วันเสาร์ที่ 29 ตุลาคม พ.ศ. 2559

Microsoft SQL Server T-SQL date and datetime formats

Microsoft SQL Server T-SQL date and datetime formats
– Date time formats – mssql datetime 
– MSSQL getdate returns current system date and time in standard internal format
SELECT convert(varchar, getdate(), 100) – mon dd yyyy hh:mmAM (or PM)
                                                                   – Oct  2 2008 11:01AM        
SELECT convert(varchar, getdate(), 101) – mm/dd/yyyy - 10/02/2008                
SELECT convert(varchar, getdate(), 102) – yyyy.mm.dd – 2008.10.02          
SELECT convert(varchar, getdate(), 103) – dd/mm/yyyy
SELECT convert(varchar, getdate(), 104) – dd.mm.yyyy
SELECT convert(varchar, getdate(), 105) – dd-mm-yyyy
SELECT convert(varchar, getdate(), 106) – dd mon yyyy
SELECT convert(varchar, getdate(), 107) – mon dd, yyyy
SELECT convert(varchar, getdate(), 108) – hh:mm:ss
SELECT convert(varchar, getdate(), 109) – mon dd yyyy hh:mm:ss:mmmAM (or PM)
                                                                    – Oct  2 2008 11:02:44:013AM  
SELECT convert(varchar, getdate(), 110) – mm-dd-yyyy
SELECT convert(varchar, getdate(), 111) – yyyy/mm/dd
SELECT convert(varchar, getdate(), 112) – yyyymmdd
SELECT convert(varchar, getdate(), 113) – dd mon yyyy hh:mm:ss:mmm
                                                                   – 02 Oct 2008 11:02:07:577    
SELECT convert(varchar, getdate(), 114) – hh:mm:ss:mmm(24h)
SELECT convert(varchar, getdate(), 120) – yyyy-mm-dd hh:mm:ss(24h)
SELECT convert(varchar, getdate(), 121) – yyyy-mm-dd hh:mm:ss.mmm
SELECT convert(varchar, getdate(), 126) – yyyy-mm-ddThh:mm:ss.mmm
                                                                   – 2008-10-02T10:52:47.513
– SQL create different date styles with t-sql string functions
SELECT replace(convert(varchar, getdate(), 111), ‘/’, ‘ ‘) – yyyy mm dd
SELECT convert(varchar(7), getdate(), 126)                 – yyyy-mm
SELECT right(convert(varchar, getdate(), 106), 8)          – mon yyyy

วันศุกร์ที่ 19 สิงหาคม พ.ศ. 2559

convert web asp.net from .net framework 2.0 to .net framework 3.5 fix Ajax return msg.d

เพิ่ม tag javascript ในหน้าที่มีการเรียกใช้ ajax

$.ajaxSetup({
            dataFilter: function (data) {
                return JSON.stringify($.parseJSON(data).d);
            }

        });

เนื่องจาก project มีการเรียกใช้หลายที่ ทำให้แก้ไขยาก ถ้าใช้วิธีนี้ไม่ต้องแก้ไข code เก่าเลย ลดงาน ลดเวลา ไม่กระทบงานเก่า

วันพุธที่ 13 มกราคม พ.ศ. 2559

เว็บเล่น file media video

ตัวอย่าง
http://www.mia-pi.ca/promo_video2.html





 ที่มา
http://www.mia-pi.ca/promo_video2.html

View Code

วันอาทิตย์ที่ 19 เมษายน พ.ศ. 2558

Error message 401.2.: Unauthorized: Logon failed due to server configuration. Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server. Contact the Web server's administrator for additional assistance.



วิธีแก้ไข
folder: %windir%\Microsoft.Net\Framework\v2.0.50.27\CONFIG\web.config
************************************
<system .web="">
        <authorization>
            <allow users="*" verbs="GET,POST">
        </allow></authorization>
</system>
************************************
แก้ไขเป็น
*********************************
<system .web="">
        <authorization>
            <allow users="*" verbs="">
        </allow></authorization>
</system>
*********************************

วันอังคารที่ 24 มีนาคม พ.ศ. 2558

Linq OrderBy Extension

ในการพัฒนาโปรแกรม ด้วย ASP.net ต้องมีการQuery ข้อมูลมาแสดงในGridView ซึ่งต้องมีส่วนของการ Sort Data แน่นอน และถ้าเราใช้ LinQ ละ? ผมจึงนำ Extension Method ใน LinQ นำมาฝาก
รูปแบบการเรียกใช้งานทำได้ดังนี้


list.OrderBy("SomeProperty");
list.OrderBy("SomeProperty DESC");
list.OrderBy("SomeProperty DESC, SomeOtherProperty");
list.OrderBy("SomeSubObject.SomeProperty ASC, SomeOtherProperty DESC");

 ที่มา
Dynamic SQL-like Linq OrderBy Extension
http://aonnull.blogspot.com/2010/08/dynamic-sql-like-linq-orderby-extension.html


C#.net Convert To VB.net By :http://converter.telerik.com/


View Code