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

搜尋意見
文章分類-Bike
[所有文章分類]
  • ASP.NET (10)
  • ASP.NET2.0 (6)
  • ASP.NET4.0 (7)
  • JavaScript (11)
  • jQuery (9)
  • FireFox (0)
  • UW系統設定 (0)
  • SQL (10)
  • SQL 2008 (7)
  • mirror (0)
  • SVN (2)
  • IE (2)
  • IIS (9)
  • IIS6 (0)
  • 閒聊 (0)
  • W3C (0)
  • 作業系統 (1)
  • C# (0)
  • CSS (3)
  • FileServer (0)
  • HTML 5 (3)
  • CKEditor (2)
  • UW.dll (3)
  • Visual Studio (4)
  • Browser (2)
  • SEO (1)
  • Google Apps (0)
  • 網站輔助系統 (0)
  • DNS (0)
  • SMTP (1)
  • 網管 (1)
  • 社群API (0)
  • SSL (0)
  • App_Inventor (0)
  • URLRewrite (0)
  • 開發工具 (0)
  • JSON (0)
  • Excel2007 (0)
  • 試題 (3)
  • LINQ (0)
  • bootstrap (0)
  • Vue (0)
  • IIS7 (0)
  • foodpanda (0)
  • 編碼 (0)
  • 資安 (0)
  • Sourcetree (0)
  • MAUI (1)
  • CMD (0)
  • my sql (0)
所有文章分類
[Bike的分類]
  • 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# (23)
  • 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
  • 用 Javascript 跨網頁讀取 cookie (Cookie cross page, path of cookie)
    ...more
  • IIS 配合 AD (Active Directory) 認証, 使用 .Net 6.0
    太感謝你了~~~你救了我被windows 認證卡了好幾天QQ...more
  • PostgreSQL 的 monitor trigger
    FOR EACH ROW 可能要改為 FOR EACH STATEMENT ...more
  • 用 Javascript 跨網頁讀取 cookie (Cookie cross page, path of cookie)
    ;;;;...more
  • 匯出 let's encryption的憑証
    1. win-acme 選擇 A: Manage renewals找到你要轉移的憑證名稱和密碼2. ...more
  • 資安問題 -- 存入 DB 後顯示內容
    伺服器隱碼問題1 寫入DB前不是當成字串就執行某些事情 (某些server 漏洞? 許功蓋?)2 寫...more
  • 匯出 let's encryption的憑証
    【注意】要打開 win-acme <<這個軟體匯出憑證...more
  • Swagger 的問題解決 (NSwag)
    DefaultController所產出的文建會讓Swagger讀不懂報錯[ApiExplorerS...more
  • 合併兩個 Expression -- Combining two expressions (Expression>)
    官方文件就有寫啊,這麼多方法不全部看個一遍說不過去吧~https://learn.microsoft...more
標籤
  • 專案
  • datagrid
  • remote
  • ti
  • [t],
  • 2482
  • ASP.NET C
  • 158
  • request,
  • Transactio
  • tim
  • 50
  • Chrome
  • ORM
  • 1
  • cros
  • 384
  • 17
  • GUI ORDER
  • javascript
  • net
  • 8
  • WU
  • aspx212112
  • apeg
  • CK
  • 三元
  • write
  • find
  • line
  • 140
  • wKFpHE57
  • vpn
  • stevenchen
  • list
  • image,
  • sql lock
  • sql ORDER
  • background
  • shop ORDER
  • rainbow
  • rOA19a3t
  • r0iMk5pz
  • ordermain
  • uw原件
  • the servic
  • sql manage
  • separatedi
  • pay介接
  • profiler
頁數 16 / 26 上一頁 下一頁
移除副檔名的 Batch
用 Chrome 下載網頁時, JS 檔的副檔名會被加上 ".下載", 要移除很多檔案的副檔名時, 可以用以下的 Batch

@echo off
for /R "C:\Path\HTML_files" %%f in (*.下載) do (
    ren "%%f" "%%~nf"
)
pause
More...
Bike, 2016/12/19 下午 12:52:56
先裝了 .NET Frame Work 再裝 IIS 再執行的指令 (錯誤訊息: Handler “PageHandlerFactory-Integrated” has a bad module “ManagedPipelineHandler” in its module list)
最近常發生, 記下來:

%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
More...
Bike, 2016/12/5 下午 03:06:18
簡單的 HTTP Relay By MVC.
客戶要求
1. 檔案只能放在 Firewall 內的後台用 Web server (Server A).
2. 使用者只能存取 DMZ 的 Web server (Server B).
3. Server B 只能用 HTTP 通過 Firewall 向 Server A 要資料.(i.e.  Server B 不能掛戴 Server A 的目錄成為虛擬目錄)

所以在 Server B 上面建立了一支程式用 HTTP 的方式讀取 Server A 的檔案再寫出去.

例如, http://ServerB/Upload/test.pdf 會讀取 http://ServerA/Upload/test.pdf 再送到 Client 端

namespace WWW.Controllers
{
    public class UploadController : Controller
    {
        // GET: Upload
        public void Index(string Filename)
        {
            //Create a stream for the file
            Stream stream = null;

            //This controls how many bytes to read at a time and send to the client
            int bytesToRead = 10000;

            // Buffer to read bytes in chunk size specified above
            byte[] buffer = new Byte[bytesToRead];

            string url = "http://admin-dev.nanya.bike.idv.tw/newnanyaback/Upload/" + Filename;

            // The number of bytes read
            try
            {
                //Create a WebRequest to get the file
                HttpWebRequest fileReq = (HttpWebRequest)HttpWebRequest.Create(url);

                //Create a response for this request
                HttpWebResponse fileResp = (HttpWebResponse)fileReq.GetResponse();

                if (fileReq.ContentLength > 0)
                    fileResp.ContentLength = fileReq.ContentLength;

                //Get the Stream returned from the response
                stream = fileResp.GetResponseStream();

                // prepare the response to the client. resp is the client Response
                var resp = HttpContext.Response;

                if (Filename.ToLower().EndsWith(".png") ||
                    Filename.ToLower().EndsWith(".jpg") ||
                    Filename.ToLower().EndsWith(".jpeg") ||
                    Filename.ToLower().EndsWith(".gif")
                    )
                {
                    resp.ContentType = "image";
                }
                else
                {
                    //Indicate the type of data being sent
                    resp.ContentType = "application/octet-stream";

                    //Name the file
                    resp.AddHeader("Content-Disposition", "attachment; filename=\"" + HttpUtility.UrlEncode(Filename, Encoding.UTF8) + "\"");
                }

                resp.AddHeader("Content-Length", fileResp.ContentLength.ToString());

                int length;
                do
                {
                    // Verify that the client is connected.
                    if (resp.IsClientConnected)
                    {
                        // Read data into the buffer.
                        length = stream.Read(buffer, 0, bytesToRead);

                        // and write it out to the response's output stream
                        resp.OutputStream.Write(buffer, 0, length);

                        // Flush the data
                        resp.Flush();

                        //Clear the buffer
                        buffer = new Byte[bytesToRead];
                    }
                    else
                    {
                        // cancel the download if client has disconnected
                        length = -1;
                    }
                } while (length > 0); //Repeat until no data is read
            }
            finally
            {
                if (stream != null)
                {
                    //Close the input stream
                    stream.Close();
                }
            }
        }
    }
}



但不是這樣就好了, 在 RouteConfig.cs 中要加上:
            routes.MapRoute(
                name: "Upload",
                url: "Upload/{filename}",
                defaults: new { controller = "Upload", action = "Index", filename = UrlParameter.Optional }
            );

此外在 Web.Config 中也要加上:

  <system.webServer>
    <handlers>
      <add name="UrlRoutingHandler_Upload"
           type="System.Web.Routing.UrlRoutingHandler, 
               System.Web, Version=4.0.0.0, 
               Culture=neutral, 
               PublicKeyToken=b03f5f7f11d50a3a"
           path="/Upload/*"
           verb="GET"/>
    </handlers>
  </system.webServer>

參考:
http://stackoverflow.com/questions/5596747/download-stream-file-from-url-asp-net

http://blog.darkthread.net/post-2014-12-05-mvc-routing-for-url-with-filename.aspx
More...
Bike, 2016/12/1 下午 09:34:30
上傳的圖片在顯示時被轉 90 度
這通常是手機或相機拍照時有旋轉造成的.

參考: http://automagical.rationalmind.net/2009/08/25/correct-photo-orientation-using-exif/

程式碼:

    void RotatePic(string pathToImageFile)
    {
        // Rotate the image according to EXIF data
        var bmp = new Bitmap(pathToImageFile);
        var exif = new EXIFextractor(ref bmp, "n"); // get source from http://www.codeproject.com/KB/graphics/exifextractor.aspx?fid=207371

        if (exif["Orientation"] != null)
        {
            RotateFlipType flip = OrientationToFlipType(exif["Orientation"].ToString());

            if (flip != RotateFlipType.RotateNoneFlipNone) // don't flip of orientation is correct
            {
                bmp.RotateFlip(flip);
                exif.setTag(0x112, "1"); // Optional: reset orientation tag
                bmp.Save(pathToImageFile, ImageFormat.Jpeg);
            }
        }

        bmp.Dispose();
    }

    private static RotateFlipType OrientationToFlipType(string orientation)
    {
        switch (int.Parse(orientation))
        {
            case 1:
                return RotateFlipType.RotateNoneFlipNone;
                break;
            case 2:
                return RotateFlipType.RotateNoneFlipX;
                break;
            case 3:
                return RotateFlipType.Rotate180FlipNone;
                break;
            case 4:
                return RotateFlipType.Rotate180FlipX;
                break;
            case 5:
                return RotateFlipType.Rotate90FlipX;
                break;
            case 6:
                return RotateFlipType.Rotate90FlipNone;
                break;
            case 7:
                return RotateFlipType.Rotate270FlipX;
                break;
            case 8:
                return RotateFlipType.Rotate270FlipNone;
                break;
            default:
                return RotateFlipType.RotateNoneFlipNone;
        }
    }
More...
Bike, 2016/12/1 下午 09:15:00
Application_BeginRequest 沒有作用, windows 2008, IIS7, MVC,
在 windows  2008 的 IIS7 跑 MVC, 會遇到 Application_BeginRequest 沒有作用, 可以在 web.config 中加一個:

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

另外聽說裝 KB980368 會是比較好的解決方法, 有空再來試試.

參考: http://blog.darkthread.net/post-2015-05-30-aspnet-mvc-on-win2008.aspx
More...
Bike, 2016/11/29 上午 09:17:41
IIS7, MVC, 404
在 .100 安裝 MVC 專案時, web.config 要記得檢查有沒有設定 UrlRoutingModule, 如下. 否則會出現 404 的錯誤.
 
<system.webServer>
  <modules>
    <remove name="UrlRoutingModule-4.0" />
    <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
  </modules>
</system.webServer>
More...
Bike, 2016/11/22 上午 06:51:17
中文難字的繁簡轉換處理
看到黑暗有一個關於中文難字的繁簡轉換處理的文章, 先記錄部份在這裡.

http://blog.darkthread.net/post-2015-03-06-strconv-half-full-width-notes.aspx

      var ncrString = toNCR("黑暗執行緒犇ABC123");
      Debug.WriteLine(ncrString); //黑暗執行緒&#29319;ABC123
      var convString = Microsoft.VisualBasic.Strings.StrConv(
        ncrString, Microsoft.VisualBasic.VbStrConv.Narrow, 1028);
      Debug.WriteLine(convString); //黑暗执行绪&#29319;ABC123
      var resultString = fromNCR(convString);
      Debug.WriteLine(resultString); //黑暗执行绪犇ABC123


    static string toNCR(string input)
    {  
      StringBuilder sb = new StringBuilder();
      Encoding big5 = Encoding.GetEncoding("big5");
      foreach (char c in input)
      {
        //強迫轉碼成Big5,看會不會變成問號
        string cInBig5 = big5.GetString(big5.GetBytes(new char[] {c}));
        //原來不是問號,轉碼後變問號,判定為難字
        if (c!='?' && cInBig5=="?")
          sb.AppendFormat("&#{0};", Convert.ToInt32(c));
        else
          sb.Append(c);
      }
      return sb.ToString();
    }
 
    static string fromNCR(string input)
    {
      return Regex.Replace(input, "&#(?<ncr>\\d+?);", (m) =>
      {
        return Convert.ToChar(int.Parse(m.Groups["ncr"].Value)).ToString();
      });
    }
More...
Bike, 2016/11/21 下午 12:40:54
.Net 支援的編碼表 From Encoding.GetEncodings
寫一下, 以備不時之需, Codepage 和 Name 可以用來取得 encoding.
CodePage, DisplayName, Name
37, IBM EBCDIC (美國-加拿大), IBM037
437, OEM 美國, IBM437
500, IBM EBCDIC (國際), IBM500
708, 阿拉伯文 (ASMO 708), ASMO-708
720, 阿拉伯文 (DOS), DOS-720
737, 希臘文 (DOS), ibm737
775, 波羅的海文 (DOS), ibm775
850, 西歐語系 (DOS), ibm850
852, 中歐語系 (DOS), ibm852
855, OEM 斯拉夫文, IBM855
857, 土耳其文 (DOS), ibm857
858, OEM 多語系拉丁文 I, IBM00858
860, 葡萄牙文 (DOS), IBM860
861, 冰島文 (DOS), ibm861
862, 希伯來文 (DOS), DOS-862
863, 加拿大法文 (DOS), IBM863
864, 阿拉伯文 (864), IBM864
865, 北歐字母 (DOS), IBM865
866, 斯拉夫文 (DOS), cp866
869, 希臘文,現代 (DOS), ibm869
870, IBM EBCDIC (多語系拉丁文 2), IBM870
874, 泰文 (Windows), windows-874
875, IBM EBCDIC (希臘現代), cp875
932, 日文 (Shift-JIS), shift_jis
936, 簡體中文 (GB2312), gb2312
949, 韓文, ks_c_5601-1987
950, 繁體中文 (Big5), big5
1026, IBM EBCDIC (土耳其拉丁文 5), IBM1026
1047, IBM 拉丁文 1, IBM01047
1140, IBM EBCDIC (美國-加拿大-歐洲), IBM01140
1141, IBM EBCDIC (德國-歐洲), IBM01141
1142, IBM EBCDIC (丹麥-挪威-歐洲), IBM01142
1143, IBM EBCDIC (芬蘭-瑞典-歐洲), IBM01143
1144, IBM EBCDIC (義大利-歐洲), IBM01144
1145, IBM EBCDIC (西班牙-歐洲), IBM01145
1146, IBM EBCDIC (英國-歐洲), IBM01146
1147, IBM EBCDIC (法國-歐洲), IBM01147
1148, IBM EBCDIC (國際-歐洲), IBM01148
1149, IBM EBCDIC (冰島-歐洲), IBM01149
1200, Unicode, utf-16
1201, Unicode (位元組由大到小), utf-16BE
1250, 中歐語系 (Windows), windows-1250
1251, 斯拉夫文 (Windows), windows-1251
1252, 西歐語系 (Windows), Windows-1252
1253, 希臘文 (Windows), windows-1253
1254, 土耳其文 (Windows), windows-1254
1255, 希伯來文 (Windows), windows-1255
1256, 阿拉伯文 (Windows), windows-1256
1257, 波羅的海文 (Windows), windows-1257
1258, 越南文 (Windows), windows-1258
1361, 韓文 (Johab), Johab
10000, 西歐語系 (Mac), macintosh
10001, 日文 (Mac), x-mac-japanese
10002, 繁體中文 (Mac), x-mac-chinesetrad
10003, 韓文 (Mac), x-mac-korean
10004, 阿拉伯文 (Mac), x-mac-arabic
10005, 希伯來文 (Mac), x-mac-hebrew
10006, 希臘文 (Mac), x-mac-greek
10007, 斯拉夫文 (Mac), x-mac-cyrillic
10008, 簡體中文 (Mac), x-mac-chinesesimp
10010, 羅馬尼亞文 (Mac), x-mac-romanian
10017, 烏克蘭文 (Mac), x-mac-ukrainian
10021, 泰文 (Mac), x-mac-thai
10029, 中歐語系 (Mac), x-mac-ce
10079, 冰島文 (Mac), x-mac-icelandic
10081, 土耳其文 (Mac), x-mac-turkish
10082, 克羅埃西亞文 (Mac), x-mac-croatian
12000, Unicode (UTF-32), utf-32
12001, Unicode (UTF-32 位元組由大到小), utf-32BE
20000, 繁體中文 (CNS), x-Chinese-CNS
20001, TCA 台灣, x-cp20001
20002, 繁體中文 (Eten), x-Chinese-Eten
20003, IBM5550 台灣, x-cp20003
20004, TeleText 台灣, x-cp20004
20005, Wang 台灣, x-cp20005
20105, 西歐語系 (IA5), x-IA5
20106, 德文 (IA5), x-IA5-German
20107, 瑞典文 (IA5), x-IA5-Swedish
20108, 挪威文 (IA5), x-IA5-Norwegian
20127, US-ASCII, us-ascii
20261, T.61, x-cp20261
20269, ISO-6937, x-cp20269
20273, IBM EBCDIC (德國), IBM273
20277, IBM EBCDIC (丹麥-挪威), IBM277
20278, IBM EBCDIC (芬蘭-瑞典), IBM278
20280, IBM EBCDIC (義大利), IBM280
20284, IBM EBCDIC (西班牙), IBM284
20285, IBM EBCDIC (UK), IBM285
20290, IBM EBCDIC (日文片假名), IBM290
20297, IBM EBCDIC (法國), IBM297
20420, IBM EBCDIC (阿拉伯文), IBM420
20423, IBM EBCDIC (希臘文), IBM423
20424, IBM EBCDIC (希伯來文), IBM424
20833, IBM EBCDIC (韓文擴充), x-EBCDIC-KoreanExtended
20838, IBM EBCDIC (泰國), IBM-Thai
20866, 斯拉夫文 (KOI8-R), koi8-r
20871, IBM EBCDIC (冰島), IBM871
20880, IBM EBCDIC (斯拉夫俄文), IBM880
20905, IBM EBCDIC (土耳其), IBM905
20924, IBM 拉丁文 1, IBM00924
20932, 日文 (JIS 0208-1990 和 0212-1990), EUC-JP
20936, 簡體中文 (GB2312-80), x-cp20936
20949, 韓文 Wansung, x-cp20949
21025, IBM EBCDIC (斯拉夫塞爾維亞文-保加利亞文), cp1025
21866, 斯拉夫文 (KOI8-U), koi8-u
28591, 西歐語系 (ISO), iso-8859-1
28592, 中歐語系 (ISO), iso-8859-2
28593, 拉丁文 3 (ISO), iso-8859-3
28594, 波羅的海文 (ISO), iso-8859-4
28595, 斯拉夫文 (ISO), iso-8859-5
28596, 阿拉伯文 (ISO), iso-8859-6
28597, 希臘文 (ISO), iso-8859-7
28598, 希伯來文 (ISO-Visual), iso-8859-8
28599, 土耳其文 (ISO), iso-8859-9
28603, 愛沙尼亞文 (ISO), iso-8859-13
28605, 拉丁文 9 (ISO), iso-8859-15
29001, 歐洲, x-Europa
38598, 希伯來文 (ISO-Logical), iso-8859-8-i
50220, 日文 (JIS), iso-2022-jp
50221, 日文 (JIS-Allow 1 byte Kana), csISO2022JP
50222, 日文 (JIS-Allow 1 byte Kana - SO/SI), iso-2022-jp
50225, 韓文 (ISO), iso-2022-kr
50227, 簡體中文 (ISO-2022), x-cp50227
51932, 日文 (EUC), euc-jp
51936, 簡體中文 (EUC), EUC-CN
51949, 韓文 (EUC), euc-kr
52936, 簡體中文 (HZ), hz-gb-2312
54936, 簡體中文 (GB18030), GB18030
57002, ISCII 梵文語系, x-iscii-de
57003, ISCII 孟加拉文, x-iscii-be
57004, ISCII 坦米爾文, x-iscii-ta
57005, ISCII 特拉古文, x-iscii-te
57006, ISCII 阿薩姆文, x-iscii-as
57007, ISCII 歐利亞文, x-iscii-or
57008, ISCII 坎那達文, x-iscii-ka
57009, ISCII 馬來亞拉姆文, x-iscii-ma
57010, ISCII 古吉拉特文, x-iscii-gu
57011, ISCII 旁遮普語, x-iscii-pa
65000, Unicode (UTF-7), utf-7
65001, Unicode (UTF-8), utf-8
More...
Bike, 2016/11/12 上午 10:12:03
做認証的位置
目前習慣是把後台的認証是做在 Master Page 裡面,

另外發現一個可以做登入檢查的地方:

lobal.asax 裡的 "Application_AcquireRequestState" 這個會發生在 Page_PreInit 之前, 而且可以使用 Session 變數. 也可以抓到所有的 Cookie.

不過剛發現一個情況, / 的 request 會執行

Application_BeginRequest
Application_AuthenticateRequest
Application_AuthorizeRequest
Application_ResolveRequestCache
Application_AcquireRequestState
Application_PreRequestHandlerExecute

兩次,

而且第一次是沒有 Session 的.. 

還要再研究....
 
More...
Bike, 2016/11/10 下午 09:47:41
機房搬遷注意事項
2016 / 10 / 30 搬機房, 有幾件事沒有做好, 記錄一下:

1. Firewall 沒設定好, 下次要一中兩個人一起設定.

2. 有一個客戶的 DNS 等了一整天才生效, 要檢查所有網站的 TTL 和  Refresh 時間, 最好都在一個小時以內.

3. Email 主機: 有些客戶原來是用 msa.hinet.net 這個 SMTP, 搬到非 Hinet 的機房後就不能寄信了.

4. 某一個客戶的 DNS 沒改好, 因為在自已的 DNS Server 上面看到有記錄, 就誤判是我們代管的, 應該要用 Hinet 或 Google 來確認 NS Record 為何. 已刪除它的 DNS  記錄.

5. 202 的 .8 網路線沒插好, 主機開起來後, 要確認可以從每一個介面 Ping 出去.

6. 新 Firewall , 內部 IP 無法連到 Virtual Server: --> 要由內部 IP 連線到 Virtual Server 測試. 最好是在 hosts 上面都有 127.0.0.1 的設定.

7. 最好不要在下半年換機房, 比較忙, 客戶的活動也比較多.

8. Windows 的 DNS 若是直接修改 DNS 檔案. 因為 SOA 的序號沒有修改, 所以 Client 伺服器要手動重新讀取資料.

9. 要記得改 TWNIC 的 DNS Server設定.
More...
Bike, 2016/11/3 上午 11:05:19
|< …78910111213141516… >|
頁數 16 / 26 上一頁 下一頁
~ Uwinfo ~