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
標籤
  • 378
  • 18
  • -5137 UNIO
  • a
  • 過期
  • javascript
  • web
  • 110
  • [U2]
  • 82
  • let
  • sourcetree
  • print 0xFF
  • windows
  • 582
  • 瘦身
  • 字串
  • loopback
  • 262
  • 318
  • .
  • 3482121121
  • iis
  • AD
  • UserHostAd
  • 8
  • asp
  • 1602
  • 欄位
  • UWInfo
  • 622
  • 174
  • validate
  • Linq
  • 0x4
  • mod
  • 140
  • 904
  • Table
  • 貼
  • ASCII
  • lucene.net
  • Su
  • 使用者
  • 網站
  • 加密
  • aspnet
  • find
  • 36
  • array
頁數 23 / 51 上一頁 下一頁
搜尋 . 結果:
刪除所有的 Active Session.
今天遇到客戶的 DB  使用空間滿了. 有  "Active Transaction" 

什麼事十日都不能做, 只好刪掉所有的 Session. 使用的 SQL 如下:

SQL 2012
USE [master];

DECLARE @kill varchar(8000) = '';  
SELECT @kill = @kill + 'kill ' + CONVERT(varchar(5), session_id) + ';'  
FROM sys.dm_exec_sessions
WHERE database_id  = db_id('MyDB')

EXEC(@kill);


​
For MS SQL Server 2000, 2005, 2008
USE master;

DECLARE @kill varchar(8000); SET @kill = '';  
SELECT @kill = @kill + 'kill ' + CONVERT(varchar(5), spid) + ';'  
FROM master..sysprocesses  
WHERE dbid = db_id('MyDB')

EXEC(@kill); 
More...
Bike, 2017/3/23 上午 10:54:39
SVN - cleanup 卡住
有時SVN資料夾檔案,簽入簽出會出錯,然後就完全不能用了
跑 cleanup之後,會出現這樣的訊息
Command: Update Error: Previous operation has not finished; run 'cleanup' if it was interrupted Error: Please execute the 'Cleanup' command. Completed!:


其實是SVN有個工作執行沒有結束,若要 kill 掉這個工作,就要使用 sqlite 工具
(SVN 是以 sqlite 來儲存資料)
1. 要下載 sqlite3.exe 主程式放在 SVN root 目錄下
2. 開啟 cmd, 執行 ​ sqlite3.exe .svn/wc.db "select * from work_queue"
3.刪除 work queue qlite3.exe .svn/wc.db "delete from work_queue"
​4. 把 SVN root 下的 sqlite3.exe 移走
More...
darren, 2017/3/2 下午 04:38:58
CKEditor, Div in A, 亂改 HTML
在 CKEditor 中, 預設 Div 不能包在 A 裡面, 如果要改變, 需加上這一段:

CKEDITOR.dtd.a.div = 1;


不要讓 CKEditor 亂改 HTML:

CKEDITOR.config.allowedContent = true;
More...
Bike, 2017/2/11 下午 04:22:03
Post File With C#
Post 的資料好像會變大, 要改 Web.config
<system.web>
    <httpRuntime requestValidationMode="2.0" maxRequestLength="1024000"/>
</system.web>



程式碼如下:

public string UploadFilesToRemoteUrl(string url, string[] files, NameValueCollection formFields = null)
    {
        string boundary = "----------------------------" + DateTime.Now.Ticks.ToString("x");

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.ContentType = "multipart/form-data; boundary=" +
                                boundary;
        request.Method = "POST";
        request.KeepAlive = true;

        Stream memStream = new System.IO.MemoryStream();

        var boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" +
                                                                boundary + "\r\n");
        var endBoundaryBytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" +
                                                                    boundary + "--");


        string formdataTemplate = "\r\n--" + boundary +
                                    "\r\nContent-Disposition: form-data; name=\"{0}\";\r\n\r\n{1}";

        if (formFields != null)
        {
            foreach (string key in formFields.Keys)
            {
                string formitem = string.Format(formdataTemplate, key, formFields[key]);
                byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
                memStream.Write(formitembytes, 0, formitembytes.Length);
            }
        }

        string headerTemplate =
            "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\n" +
            "Content-Type: application/octet-stream\r\n\r\n";

        for (int i = 0; i < files.Length; i++)
        {
            memStream.Write(boundarybytes, 0, boundarybytes.Length);
            var header = string.Format(headerTemplate, "uplTheFile", files[i]);
            var headerbytes = System.Text.Encoding.UTF8.GetBytes(header);

            memStream.Write(headerbytes, 0, headerbytes.Length);

            using (var fileStream = new FileStream(files[i], FileMode.Open, FileAccess.Read))
            {
                var buffer = new byte[1024];
                var bytesRead = 0;
                while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
                {
                    Response.Write("bytesRead: " + bytesRead.ToString() + "<br>");
                    memStream.Write(buffer, 0, bytesRead);
                }
            }
        }

        memStream.Write(endBoundaryBytes, 0, endBoundaryBytes.Length);
        request.ContentLength = memStream.Length;

        using (Stream requestStream = request.GetRequestStream())
        {
            memStream.Position = 0;
            byte[] tempBuffer = new byte[memStream.Length];
            memStream.Read(tempBuffer, 0, tempBuffer.Length);
            memStream.Close();
            requestStream.Write(tempBuffer, 0, tempBuffer.Length);
        }

        try
        {
            using (var response = request.GetResponse())
            {
                Stream stream2 = response.GetResponseStream();
                StreamReader reader2 = new StreamReader(stream2);
                return reader2.ReadToEnd();
            }
        }
        catch (Exception ex)
        {
            return (ex.ToString());
            throw;
        }
    }
More...
Bike, 2017/1/12 下午 08:21:09
還原資料庫後不用刪除帳號再新增的方法 (SQL User)
先在 Server 上面建立好同名的帳號, 然後可以用這個指令

sp_change_users_login 'Auto_Fix', 'username'


若想要連 Server 上的帳號一併建立: 

sp_change_users_login [ @Action = ] 'action'
    [ , [ @UserNamePattern = ] 'user' ]
    [ , [ @LoginName = ] 'login' ]
    [ , [ @Password = ] 'password' ]
[;]

[ @Action= ] 'action'
描述此程序所要執行的動作。 動作是varchar (10)。 通常是 'Auto_Fix'

[ @UserNamePattern= ] 'user'
這是目前資料庫中的使用者名稱。 使用者是sysname,預設值是 NULL。
[ @LoginName= ] 'login'
這是 SQL Server 登入的名稱。 登入是sysname,預設值是 NULL。
[ @Password= ] 'password'
指派給新的密碼SQL Server藉由指定建立登入Auto_Fix。 如果符合的登入已經存在,對應的使用者和登入和密碼會被忽略。 如果符合的登入不存在,則 sp_change_users_login 會建立新SQL Server登入,並指派密碼當做新登入的密碼。 密碼是sysname,而且不可以是 NULL。


參考: https://msdn.microsoft.com/zh-tw/library/ms174378.aspx
More...
Bike, 2017/1/3 下午 02:25:38
NOPI 取得 Excel 中公式欄位的值
​                    If row.GetCell(j).CellType = CellType.FORMULA Then    '== v.1.2.4版修改
                        D_dataRow(j) = row.GetCell(j).NumericCellValue
                        '-- 表示格子裡面,公式運算後的「值」,是數字(Numeric)。而非抓到「公式」。
                    Else
                        D_dataRow(j) = row.GetCell(j).StringCellValue   '--每一個欄位,都加入同一列 DataRow
                    End If

參考: https://dotblogs.com.tw/mis2000lab/2011/06/09/npoi_excel_formula_value
More...
Bike, 2016/12/23 下午 06:49:27
用 Jquery 增加 Option 的漂亮寫法.
用 Jquery 增加 Option 的漂亮寫法.

$("#select").append($("<option></option>").attr("value", "值").text("文字"));


其它更多可以參考: ​https://dotblogs.com.tw/alanjiang/2011/01/26/21061
More...
Bike, 2016/12/20 下午 09:14:54
移除副檔名的 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
|< …14151617181920212223… >|
頁數 23 / 51 上一頁 下一頁
~ Uwinfo ~