2016年12月28日 星期三

.Net Core HttpClient GetAsAsync執行時過慢問題

參考文章: HttpClient.GetAsync is slow in dnxcore50 compared to dnx461

MVC 5就用過 HttpClient,一切正常,但在開發 Line Bot時用 HttpClient呼叫已經在服務的 API時就發生斷片問題,但也不是常常發生,本來以為是我程式寫法的問題,後來追蹤時發現會一直卡在 GetAsAsync,所以上網也找到相關文章,其建議是在產生 HttpClient時先新增一個 HttpClientHandler並把其 attribute UseProxy設為 false, 這樣應該可以改善速度的問題,改寫之後果然不會再發生過慢的問題了。

2016年12月26日 星期一

Use Line Bot to search extensions and MVPN numbers of the enterprise

Last time I shared my first Line Bot 使用 ASP.Net Core Web API 實作 Line Bot webhook callback. It is a funny bot to show what kind of person is by entering a name. if you enter a name "Catton", it would answer "He is a handsome man."

Because of first bot, it gave me a inspiration to develop another Lin Bot that could facilitate to contact  other colleagues easily. Especially for the enterprise that already has implemention of MVPN.

First of all, here is the wiki to introduce what is MVPN, Mobile virtual private network.  You can dial a short number, maybe 5 or 4 digits, to communicate the colleague whose mobile phone is in your enterprise MVPN group.

Inside the enterprise, I can build a web to search someone's extension or MVPN number by entering name, employee number or department name. Here is the screenshot of web-searching.




















2016年12月18日 星期日

使用 asp.net core實作一個類 google blog的網站



 

之前有分享過 試作 CKEditor 圖片選擇器 ( image upload ),利用 ckeditor和客制 image picker
來達成圖片選取,但是圖片的處理、儲存還沒實作完成,最近剛好寫完預算系統,所以利用空檔來繼續完成這個部份,完成工作內容如下:

2016年12月7日 星期三

ASP.NET Core Render View to String in Controller

參考文章:
ASP.NET Core Render View to String
Render a Razor View containing a URL to a string in ASP.NET Core

這個目的是直接在 controller直接產生 partial view的字串再回傳至 view ajax result,然後直接把某個 element換掉或作內文休改,這種方式當然也有其它的方式達成,但直接在 contorller內產生 view string也是可以試試,因為在 Asp.net MVC 5也有類似的作法或是直接使用 westwind的 library。但在 Asp.net Core就不能直接拿來用。所以參考上面的分享文章就可以達到目的了。

AntiXss Library for Asp.Net Core

之前在 Asp.Net MVC 5時會使用 微軟的 AntiXSS Library
而在 Core專案的 Library,我有找到一個叫 SmallCode.AspNetCore.AntiXSS
這個 library不只在 controller內使用 HtmlFilter.Instance.SanitizeHtml 方法還在 view有提供 tag helper @Html.Sanitized可以使用。 如果需要的話可以使用 nuget下載使用。