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

搜尋意見
文章分類-#Author#
[所有文章分類]
所有文章分類
  • ASP.NET (48)
  • ASP.NET2.0 (15)
  • ASP.NET4.0 (34)
  • JavaScript (49)
  • jQuery (26)
  • FireFox (4)
  • UW系統設定 (3)
  • SQL (39)
  • SQL 2008 (25)
  • mirror (4)
  • SVN (4)
  • IE (9)
  • IIS (20)
  • IIS6 (1)
  • 閒聊 (7)
  • W3C (6)
  • 作業系統 (9)
  • C# (24)
  • CSS (12)
  • FileServer (1)
  • HTML 5 (11)
  • CKEditor (3)
  • UW.dll (13)
  • Visual Studio (16)
  • Browser (8)
  • SEO (1)
  • Google Apps (3)
  • 網站輔助系統 (4)
  • DNS (5)
  • SMTP (4)
  • 網管 (11)
  • 社群API (3)
  • SSL (4)
  • App_Inventor (1)
  • URLRewrite (2)
  • 開發工具 (6)
  • JSON (1)
  • Excel2007 (1)
  • 試題 (3)
  • LINQ (1)
  • bootstrap (0)
  • Vue (3)
  • IIS7 (3)
  • foodpanda (2)
  • 編碼 (2)
  • 資安 (3)
  • Sourcetree (1)
  • MAUI (1)
  • CMD (1)
  • my sql (1)
最新回應
  • Newtonsoft.Json.JsonConvert.DeserializeObject 失敗的情況
    test...more
  • dotnet ef dbcontext scaffold
    ...more
  • [ASP.NET] 利用 aspnet_regiis 加密 web.config
    ...more
  • IIS ARR (reverse proxy) 服務安裝
    ...more
  • [錯誤訊息] 請加入 ScriptResourceMapping 命名的 jquery (區分大小寫)
    ...more
  • 用 Javascript 跨網頁讀取 cookie (Cookie cross page, path of cookie)
    ...more
  • 線上客服 - MSN
    本人信箱被盜用以致資料外洩,是否可以請貴平台予以協助刪除該信箱之使用謝謝囉...more
  • 插入文字到游標或選取處
    aaaaa...more
  • IIS 配合 AD (Active Directory) 認証, 使用 .Net 6.0
    太感謝你了~~~你救了我被windows 認證卡了好幾天QQ...more
  • PostgreSQL 的 monitor trigger
    FOR EACH ROW 可能要改為 FOR EACH STATEMENT ...more
標籤
  • ? ORDER BY
  • IP
  • if21211211
  • 檔案
  • max
  • [u2]
  • MS8qKi9hTm
  • 4426-4292
  • 死
  • 8
  • 100
  • 412
  • SQL2008
  • en order b
  • 備份21211211
  • 5986
  • U2
  • 28
  • config ord
  • HTML 的上標字與
  • 232
  • .
  • mibs
  • 0,
  • aHR0cDovL3
  • ClientIP
  • Data
  • images
  • ad
  • 0
  • a
  • cookie
  • ie
  • .net
  • RSA
  • aspnet ORD
  • SU
  • List.where
  • -4768
  • bike
  • c
  • 288
  • 防火牆
  • vs
  • 梨子
  • Rf
  • Ubuntu
  • dns
  • jquery
  • svn
頁數 3 / 14 上一頁 下一頁
搜尋 IP 結果:
轉發 API
HttpWebRequest vs HttpClient httpClient

Post File
Token
Cookie
檔案不落地

以下的程式碼不能縮寫: 
var oldFilename = content.Headers.ContentDisposition.FileName.Trim('\"');
            var contentStream = await content.ReadAsStreamAsync();

            return await PostFile(url, inputName, contentStream, oldFilename,
                authorizationToken, IsAddIpHeaders);
        }
More...
Bike, 2021/12/31 下午 02:50:10
前端處理網址組網址工具
在後端部分,因為有uw元件,在處理url時已經很好處理了
但是在JavaScript因為我們沒有固定js在使用,
因此提供一套簡易使用網址處理工具
thisPage.ParameterByName(key) //取得網址上特定參數
thisPage.OriUrl(key) //中間一段提供修改變數的功能


    <script>
        var thisPage = {
            Init: function () {
                thisPage.InitPageInput();

                $("body")
                    ;
                thisPage.ChangeEvent();
            },
            ParameterByName: function (targetKey) {
                var res = null;
                const urlSearchParams = new URLSearchParams(window.location.search);
                const params = Object.fromEntries(urlSearchParams.entries());
                for (const [key, value] of Object.entries(params)) {
                    if (targetKey.trim().toLocaleLowerCase() === key) {
                        res = value;
                    }
                }
                return res;
            },
            OriUrl: function () {
                var arrayUrl = [];
                arrayUrl.push(window.location.protocol);//https:
                arrayUrl.push("//");
                arrayUrl.push(window.location.hostname);//blog.uwinfo.com.tw
                if (window.location.port.length > 0) {
                    //大多情況,不用特別指定port
                    arrayUrl.push(":");
                    arrayUrl.push(window.location.port);//80
                }
                arrayUrl.push(window.location.pathname);//post/Edit.aspx
                //換一套寫法
                //arrayUrl.push(window.location.search);//?Id=321
                const urlSearchParams = new URLSearchParams(window.location.search);
                const params = Object.fromEntries(urlSearchParams.entries());
                var ayyarQueryString = [];
                //這邊可以加工增加額外的key值
                for (const [key, value] of Object.entries(params)) {
                    if (value.trim().length > 0) {
                        //這邊要注意中文需要encode
                        ayyarQueryString.push(key + "=" + encodeURIComponent(value));
                    }
                }
                if (ayyarQueryString.length > 0) {
                    arrayUrl.push("?");
                    arrayUrl.push(ayyarQueryString.join('&'));
                }
                return arrayUrl.length > 0 ? arrayUrl.join('') : '';
            },
            InitPageInput: function () {
                const urlSearchParams = new URLSearchParams(window.location.search);
                const params = Object.fromEntries(urlSearchParams.entries());
                for (const [key, value] of Object.entries(params)) {
                    $('input[name=' + key + ']').val(value);
                    //這邊因為input有多種不同輸入方式,可以自行編輯
                    //$('select[name=' + key + ']').val(value);
                    //$('textarea[name=' + key + ']').html(value);
                }
            },
            ChangeEvent: function () {

            },
        }
        $(function () {
            thisPage.Init();
        });
    </script>
More...
Doug, 2021/10/1 下午 12:19:30
衝碼問題 許功蓋 Big5 ASCII
衝碼問題[編輯]
因為低位元字元中包含了程式語言、shell、script中,字串或命令常會用到的特殊字元,例如0x5C「\」、0x7C「|」等。「\」在許多用途的字串中是當作轉義符號,例如\n(換行)、\r(歸位)、\t(tab)、\\(\本身符號)、\"(引號)等等。而「|」在UNIX作業系統中大多當作命令管線的使用,如"ls -la | more"等等。如果在字串中有這些特殊的轉義字元,會被程式或直譯器解釋為特殊用途。但是因為是中文的原因,故無法正確解釋為上面所述的行為,因此程式可能會忽略此轉義符號或是誤當作轉義符號而中斷執行。若此,就違反了使用者本來要當成中文字元一部份使用的本意。[11]
低位元字元與ASCII重疊的字元如下︰
@ A-Z [ \ ] ^ _ ` a-z { | } ~
在常用字如「功」(0xA55C)、「許」(0xB35C)、「蓋」(0xBB5C)、「育」(0xA87C)中時常出現,造成了許多軟體無法正確處理以Big5編碼的字串或檔案。這個問題被戲謔性地人名化,稱為「許功蓋」或「許蓋功」(這三個字都有這種問題)。
一般的解決方法,是額外增加「\」的字元,因為「\\」會被解釋為「\」,所以「成功\因素」這個字串就能無誤地被程式當作「成功因素」的字串來處理。但是額外的困擾是,有些輸出功能並不會把「\」當作特殊字元看待,所以有些程式或網頁就會錯誤地常常出現在「許功蓋」這些字後面多了「\」。[11]

參考資料
zh.wikipedia.org/wiki/大五碼
More...
sean, 2020/12/30 下午 03:00:46
最簡單的 SQL Availability Group (沒有 Active Directory, 也沒有 Shared Storage)
1. 安裝 Failover-Clustering
Install-WindowsFeature Failover-Clustering –IncludeManagementTools


2. 建立 Cluster 用的帳號, 並加入管理員群組 (記得要換密碼
net user /add clustadm Sup33P@ssw0Rd!
net localgroup administrators clustadm /add


參考以下四篇文章, 有些地方可能要改一下, 有空來做一份中文版的.


https://www.mssqltips.com/sqlservertip/4951/deploy-a-windows-server-2016-failover-cluster-without-active-directory-part-1/
https://www.mssqltips.com/sqlservertip/4962/deploy-a-windows-server-2016-failover-cluster-without-active-directory--part-2/

https://www.mssqltips.com/sqlservertip/4991/implement-a-sql-server-2016-availability-group-without-active-directory-part-1/
https://www.mssqltips.com/sqlservertip/4996/implement-a-sql-server-2016-availability-group-without-active-directory-part-2/


這個也可以參考, 有很多指令碼, 可以省不少時間:

http://woshub.com/workgroup-failover-cluster-windows-server-2016/
More...
Bike, 2020/9/8 上午 08:14:15
命名規則

名命規則

C#: 

    參數, 區域變數: 小駝峰(CamelCasing)
    其它: 大駝峰(PascalCasing)
    參考:
    
https://docs.microsoft.com/zh-tw/dotnet/standard/design-guidelines/naming-guidelines

Javascript:
    小駝峰(CamelCasing)


網址:
    全小寫, 用 - (減號) 分隔單字
    參考:

    https://www.seoseo.com.tw/article_detail_609.html
    https://blog.miniasp.com/post/2011/01/14/Avoid-using-underline-as-domain-name-character
    http://epaper.gotop.com.tw/pdf/acn023600.pdf


class 名命 HTML : 
    全小寫, 用 - (減號) 分隔單字 

複合字範列:
Pascal Camel Not
BitFlag bitFlag Bitflag
Callback callback CallBack
Canceled canceled Cancelled
DoNot doNot Don't
Email email EMail
Endpoint endpoint EndPoint
FileName fileName Filename
Gridline gridline GridLine
Hashtable hashtable HashTable
Id id ID
Indexes indexes Indices
LogOff logOff LogOut
LogOn logOn LogIn
Metadata metadata MetaData, metaData
Multipanel multipanel MultiPanel
Multiview multiview MultiView
Namespace namespace NameSpace
Ok ok OK
Pi pi PI
Placeholder placeholder PlaceHolder
SignIn signIn SignOn
SignOut signOut SignOff
UserName userName Username
WhiteSpace whiteSpace Whitespace
Writable writable Writeable
DateTimePicker dateTimePicker DatetimePicker
More...
Bike, 2020/7/28 上午 08:00:08
用 certbot 申請 wildcard SSL 憑証
1. 在這裡下載 https://certbot.eff.org/lets-encrypt/windows-other.html

2. 安裝下載的程式

3. 用 cmd (管理員模式, 執行以下指令)
certbot certonly --manual --agree-tos -d "*.bike.idv.tw" -d "bike.idv.tw" --email bikehsu@gmail.com --preferred-challenges dns --manual-public-ip-logging-ok --server https://acme-v02.api.letsencrypt.org/directory

4. 會需要在 DNS Server 上建立一個 TXT 記錄.

5. 下載的格式是 pem, 可以在這裡轉成 IIS 用的 pfx 格式. https://decoder.link/converter, 轉檔時, "不"要用 fullchain

6. 用這個指令可以顯示所有 certbot 申請的憑証 "certbot certificates"

7. "certbot renew" 可以 renew  certificate, 需要測試.
More...
Bike, 2020/7/19 下午 05:11:45
在 CentOS 上面啟動多個 .Net Core 的網站
1. 參考這裡設定第一個網站:
https://blog.johnwu.cc/article/centos-asp-net-core-neginx.html
注意, 文章中有一個錯誤:
/etc/nginx/conf.d/my-website.conf 的第 27 行, 應該是 include /etc/nginx/conf.d/default_proxy_settings;

2.  因為要避開 5000 port, 所以修改第二個網站的 appsettings.json, 讓第二個網站開在 5002 port, 如下.
{
"Logging": {
    "LogLevel": {
     "Default": "Information",
     "Microsoft": "Warning",
     "Microsoft.Hosting.Lifetime": "Information"
    }
},
"Kestrel": {
        "EndPoints": {
                "Http": {
                        "Url": "http://localhost:5002"
                }
        }
},
"AllowedHosts": "*"
}


3. 新增 /etc/nginx/conf.d/my-website2.conf, 要注意
    A. portal2
    B. server localhost:5002
    C. server_name coretest2.bike.idv.tw
    當然 SSL 憑証的檔名也要記得改.

upstream portal2 {
    # localhost:5000 改成 ASP.NET Core 所監聽的 Port
    server localhost:5002;
}

server {
    # 只要是透過這些 Domain 連 HTTP 80 Port,都會轉送封包到 ASP.NET Core
    listen 80;
    # 可透過空白區分,綁定多個 Domain
    server_name coretest2.bike.idv.tw;
    location / {
        proxy_pass http://portal2/;
        include /etc/nginx/conf.d/default_proxy_settings;
    }
}

# 用 HTTPS 必須要有 SSL 憑證,如果沒有要綁定 SSL 可以把下面整段移除
server {
    # 只要是透過這些 Domain 連 HTTPS 443 Port,都會轉送封包到 ASP.NET Core
    listen 443 ssl;
    server_name coretest2.bike.idv.tw;
    ssl_certificate /etc/nginx/ssl/coretest2.bike.idv.tw.crt;
    ssl_certificate_key /etc/nginx/ssl/coretest2.bike.idv.tw.key;

    location / {
        proxy_pass http://portal2/;
        include /etc/nginx/conf.d/default_proxy_settings;
    }
}


改完後就可以用了.

以下是 https://blog.johnwu.cc/article/centos-asp-net-core-neginx.html 抄過來的一些檔案, 作為備份:

setup-aspnet-core.sh
#!/bin/bash

main() {
    sudo yum -y install epel-release
    sudo yum -y update

    install_nginx
    install_dotnet

    sudo firewall-cmd --add-service=http --permanent
    sudo firewall-cmd --add-service=https --permanent
    sudo firewall-cmd --reload
}

install_nginx() {
    echo "###################################"
    echo "########## Install Nginx ##########"
    echo "###################################"
    sudo yum -y install httpd-tools nginx
    sudo setsebool -P httpd_can_network_connect on
    sudo sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
    sudo setenforce 0
    sudo systemctl enable nginx
    sudo systemctl restart nginx
}

install_dotnet() {
    echo "###########################################"
    echo "########## Install .NET Core 2.2 ##########"
    echo "###########################################"
    sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm
    sudo yum -y install aspnetcore-runtime-2.2
}

main "$@"


用以下指令執行:
sudo sh setup-aspnet-core.sh



/etc/systemd/system/my-website.service, (/bin/dotnet 有可能是 /usr/bin/dotnet)
[Unit]
# Description=<此服務的摘要說明>
Description=MyWebsite

[Service]
# WorkingDirectory=<ASP.NET Core 專案目錄>
WorkingDirectory=/usr/share/my-website

# ExecStart=/bin/dotnet <ASP.NET Core 起始 dll>
ExecStart=/bin/dotnet MyWebsite.dll

# 啟動若失敗,就重啟到成功為止
Restart=always
# 重啟的間隔秒數
RestartSec=10

# 設定環境變數,注入給 ASP.NET Core 用
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target


服務相關指令:
# 開啟,開機自動啟動服務
systemctl enable my-website.service

# 關閉,開機自動啟動服務
systemctl disable my-website.service

# 啟動服務
systemctl start my-website.service

# 重啟服務
systemctl restart my-website.service

# 停止服務
systemctl stop my-website.service

# 查看服務狀態
systemctl status my-website.service


/etc/nginx/conf.d/default_proxy_settings
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;


/etc/nginx/conf.d/my-website.conf
upstream portal {
    # localhost:5000 改成 ASP.NET Core 所監聽的 Port
    server localhost:5000;
}

server {
    # 只要是透過這些 Domain 連 HTTP 80 Port,都會轉送封包到 ASP.NET Core
    listen 80;
    # 可透過空白區分,綁定多個 Domain
    server_name demo.johnwu.cc example.johnwu.cc;
    location / {
        proxy_pass http://portal/;
        include /etc/nginx/conf.d/default_proxy_settings;
    }
}

# 用 HTTPS 必須要有 SSL 憑證,如果沒有要綁定 SSL 可以把下面整段移除
server {
    # 只要是透過這些 Domain 連 HTTPS 443 Port,都會轉送封包到 ASP.NET Core
    listen 443 ssl;
    server_name demo.johnwu.cc;
    ssl_certificate /etc/nginx/ssl/demo.johnwu.cc_bundle.crt;
    ssl_certificate_key /etc/nginx/ssl/demo.johnwu.cc.key;

    location / {
        proxy_pass http://portal/;
        include /etc/nginx/conf.d/default_proxy_settings;
    }
}


Nginx 重新啟動:
# 檢查 Nginx 的設定是否有誤
nginx -t

# 若沒有錯誤,即可套用
nginx -s reload
More...
Bike, 2020/7/7 上午 08:01:43
在 IIS 安裝 Let's Encrypt 的 SSL, 且可以設定自動更新
可以在這裡下載 

https://pkisharp.github.io/win-acme/

或是到

https://github.com/PKISharp/win-acme/releases 

下載 x64.pluggable.zip 的檔案

執行 wacs.exe,  然後看說明就可以囉.

wacs.exe --renew 會自動設定更新排程..

.100 可以在這裡找到檔案.
C:\Users\Administrator\win-acme

.195 可以在這裡找到
C:\Users\Administrator\win-acme.v2.1.6.773.x64.pluggable
More...
Bike, 2019/12/13 下午 06:32:01
使用 Swiper 時, Mobile 版不能設定 slidesPerGroup, 否則會看到最後一組商品.
有點怪的 bug, mobile 版的 slidesPerGroup 只能設為 1

    var slidesPerGroup = 5;
    if (S3JS.isMobile()) {
        slidesPerGroup = 1; // 很奇怪, Mobile 版時, 若是設定 slidesPerGroup = 5 時, 剛進入時會看到最後一組商品.
    }
    //beauty-coin-exchange-loading
    var swiperPreview = new Swiper('.beauty-coin-exchange-swiper', {
        slidesPerView: 5,
        slidesPerColumn: 1,
        slidesPerGroup: slidesPerGroup,
        spaceBetween: 0,
        loop: true,
        breakpoints: {
            768: {
                slidesPerView: 4.3,
                spaceBetween: 10,
            }
        },
        nextButton: '.beauty-coin-next',
        prevButton: '.beauty-coin-prev',
    });
More...
Bike, 2019/11/22 下午 04:41:11
把 yyyymmdd 轉換成 yyyy-mm-dd 的神奇 javascript
試試這個:
"20190101".replace(/(\d{4})(\d{2})(\d{2})/g, '$1-$2-$3')

取得 yyyyMMdd 的方法
var D = new Date();
D.toISOString().slice(0,10).replace(/-/g,"");
More...
Bike, 2019/8/21 下午 04:47:55
|< 12345678910… >|
頁數 3 / 14 上一頁 下一頁
~ Uwinfo ~