Katsuobushi

依賴注入 Dependency injection

依賴注入 Dependency injection

ASP.NET中RenderSection的作用

專案中的各個Page會被插入到_Layout.cshtml裡@RenderBody()的位置,與主版面整合。若Page中的某段程式不想被放在body內時,可以使用Section及RenderSection改變程式碼在_Layout.cshtml中的插入位置。

叢集索引與非叢集索引

通常資料庫在尋找資料是逐行檢查,看看每一筆資料是否符合條件,若符合則拿出,不符合就往下一筆直到結束,稱為Full table scan。隨著資料量越來越大,查找的時間也會跟著變慢,使用Index可以加快查詢速度。

Webpack設定多個entry及output

預設的Webpack使用單一entry及output,若需要多個entry及output可以在webpack.config.js中加入一個函式取得目錄內的所有檔案,將所有檔案加入至entry中。

Vue3錯誤訊息 Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js".

從原本用CDN載入Vue,轉換為用npm載入並用webpack打包的過程中發生了錯誤,原因與Vue的使用環境有關。

Vue3錯誤訊息 Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js".

從原本用CDN載入Vue,轉換為用npm載入並用webpack打包的過程中發生了錯誤,原因與Vue的使用環境有關。

ASP.NET Core使用Middleware進行例外處理

當API被呼叫且發生例外時,不太會希望預設的錯誤訊息被傳回給使用者,在C#中可以使用try catch攔截錯誤訊息。但在每個可能會發生錯誤的地方都加上try catch相當繁瑣,使用Middleware可以捕捉錯誤訊息,並在返回給使用者之前統一處理,不僅可以節省開發時間,還能將錯誤訊息攔截,避免洩漏過多內部訊息給使用者,提高安全性。

比較JavaScript中assign與replace的差異

比較JavaScript中assign與replace的差異