跳到主要內容

發表文章

[.Net] EF 無法載入指定的中繼資料資源(Unable to load the specified metadata resource)

參考保哥的這份說明 關於 Entity Framework 獨立放在 DAL 專案的注意事項 主要是去修改連線字串的 metadata //-- 若你的  CSDL 、 SSDL  與  MSL  三個檔案是設定內嵌在輸出組件中,你就必須在設定 Entity Framework 連線參數時將上述  metadata  標注  *  的部分修改成 組件名稱 ,這樣就能正確載入 Entity Framework 了,如下範例: metadata=res:// 組件名稱 /AdventureWorksLT.csdl | res:// 組件名稱 AdventureWorksLT.ssd l | res:// 組件名稱 /AdventureWorksLT.msl; provider=System.Data.SqlClient; provider connection string="Data Source=.\sqlexpress;Initial Catalog=AdventureWorksLT;Integrated Security=True;MultipleActiveResultSets=True"

[Excel] PASSWORD protection of Excel file.

由於NPOI無法做到excel加密的功能, 所以在網路上找了一下,發現有兩個元件可以用 1. Microsoft.Office.Interop.Excel 2. Excel Jetcell .NET Microsoft.Office.Interop.Excel 是標準的MS套件,但使用上不是很好用,而且並不支援asp.net的環境使用 所以最後選了 Excel Jetcell .NET  作為使用的套件 用法很簡單 ExcelWorkbook Wbook = new ExcelWorkbook(); //Add new worksheet to workbook. Wbook.Worksheets.Add("Sheet1"); Wbook.Worksheets[0].Cells["A1"].Value = "sample XSL writing"; Wbook.Options.Password = "123";  //Set password //Write .xls file. MemoryStream ms = Wbook.WriteXLS(); string FileName = "test.xls"; return File(ms.ToArray(), "application/vnd.ms-excel", FileName);

[windows] 自建WSUS Client設定

1 執行gpedit.msc 開啟[本機群組原則編輯器] 2.選擇[本機電腦原則]>[電腦設定]>[系統管理範本]>[windows元件]>[windows update] 3.選擇[指定近端內部網路Microsoft更新服務的位置] 4.設為[已啟用],並設定[設定偵測更新的近端內部網路更新服務]與[設定近端內部網路統計伺服器]到自己架設的WSUS主機 設定參數如:http://Your_domain_or_ip:8530

[IIS]force HTTPS using a web.config file

   自架的IIS 要先安裝這個套件   URL Rewrite   如果在azure上的app就不需要   然後在web.config下的 [system.webServer] 區段   填入以下內容    [rewrite]       [rules]         [rule name="HTTP to HTTPS redirect" stopprocessing="true"]           [match url="(.*)"]           [conditions]             [add ignorecase="true" input="{HTTPS}" pattern="off"]           [/add][/conditions]           [action redirecttype="Found" type="Redirect" url="https://{HTTP_HOST}/{R:1}"]         [/action][/match][/rule]       [/rules]     [/rewrite]

[Bootstrap] Bootstrap suppor IE8

使用 html5shiv.js 可以讓 IE6 IE7 IE8 支援 HTML5 標籤的 JavaScript,下載網址: https://github.com/aFarkas/html5shiv 使用 css3-mediaqueries.js 可以讓不支援 Media Queries 的瀏覽器透過 Javascript 的方式也能支援。 https://code.google.com/p/css3-mediaqueries-js/ Bootstrap的官網提到,IE8 和 IE9 是有支援的,但是,很多CSS3属性和HTML5元素 -- 例如,圓角矩形和投影 -- 卻是沒有支援的。因此,IE8 需要Respond.js的配合才能實現對媒體查詢(media query)的支持。 http://getbootstrap.com/getting-started/#support-ie8-ie9 https://github.com/scottjehl/Respond

[Azure] asp.net upload file to Azure

Dim connstr As String = String.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1};", accountName, accountKey) Dim storageAccount As CloudStorageAccount = CloudStorageAccount.Parse(connstr) '//建立 Blob 服務用戶端 '//CloudBlobClient 類別可擷取 Blob 儲存體中儲存的容器和 Blob Dim blobClient As CloudBlobClient = storageAccount.CreateCloudBlobClient() '//依照名稱找尋容器 Dim container As CloudBlobContainer = blobClient.GetContainerReference(containerName) '//如果容器不存在就建立 container.CreateIfNotExists() '//設定容器權限權限 container.SetPermissions(New BlobContainerPermissions With {.PublicAccess = access}) Dim tempF as new HttpPostedFileBase Dim blockBlob As CloudBlockBlob = container.GetBlockBlobReference(tempF.FileName) blockBlob.Properties.ContentType = tempF.ContentType Dim ms As MemoryStream tempF.InputStream.CopyTo(ms) ms.Seek(0, SeekOrigin.Begin) '使用MemoryStream 務必要使用seek 將指標回到起點 blockBlob.UploadFromStream(ms) Dim Url As String = blockBlob.StorageUri....