Edi Wang

.NET and Azure Developer

Web Development HTML, JavaScript, CSS

Solving "npm install" ECONNRESET Error on Azure DevOps

A few months ago, my Angular project on Azure DevOps started to have build failure very often. Error message is "npm ERR! network read ECONNRESET", which indicates npm can't connect to internet. This problem does not happen every time, usually re-run failed jobs several times can produce a good build. But still, this is very annoying. So, I took some time to investigate and solve it. …

Azure DevOps NPM

How to Activate Kendo UI License in Azure Static Web Apps Without Exposing Secret Value

I have an open-source project that uses Kendo UI for Angular. In order for users to have BYOL model, I could not include the license file in my public repository. There is no example of how to activate Kendo license during SWA build process. Let's see how to activate Kendo UI license during the build process of Azure Static Web Apps without including the license itself in repository. …

Azure Kendo UI GitHub

Deploy to Azure Static Web App from Local Machine without GitHub Action

When creating Azure Static Web App in Azure portal. The deployment options did not provide clear instructions for how to deploy without creating a project and CI/CD pipeline on GitHub or Azure DevOps. Many times, we just want to deploy a simple one-time project from a local computer. Let's see how to do this. …

Azure

Make NPM Install with Legacy Peer Deps in Azure Static Web Apps Builds

After upgrading a JS library, GitHub Action for build and deploy Azure Static Web Apps blows up sky high. According to the error message. npm install command need to run with --legacy-peer-deps. However, there is no step of npm install in Azure Static Web Apps's yml file. How can we tell npm to use legacy peer deps? …

Azure NPM

How to Add Parameters for 'npm install' in Azure DevOps

Recently my Azure DevOps build pipeline failed because Azure is using npm 8.x, which will have issue for angular projects when running `npm install`.  This is a known issue which can be solved by using `--legacy-peer-deps` or `--force` for the `npm install` command. However, Azure DevOps's npm task does not take parameters by default. Let's see how we can use these parameters in Azure DevOps. …

Azure DevOps NPM

Blazor WASM 实现人民币大写转换器

.NET 5 正式发布已经有一段时间了,其中 Blazor 技术是该版本的亮点之一。作为微软技术的被坑者,年少的我曾经以为 SilverLight 能血虐 Flash,Zune 能团灭 iPod,WP 能吊打 iPhone,UWP 能统一全平台…… 可是后…… 最终步入大龄程序员的我发现,只有陪伴了我将近 20 年的 ASP.NET 还没有完蛋。于是我这两天花了点时间,尝试将我的一个 UWP 小工具用 Blazor 重写,分享给大家。 无法抢救的 UWP “人民币大写转换器” 是我年少无知时开发的小工具之一,它的主要功能有: - 将数字金额转化为大写中文 - 复制结果 - 使用中文语音朗读结果 - 显示参照表 可惜 UWP 不论是充满 Bug 的 SDK,Runtime,还是微软的龟速更新与混乱的规划,都已经无可救药了,是时候给应用找个新家了。 Blazor Blazor 是 .NET …

.NET Blazor WASM

如何解决AngularJs在IE下取数据总是缓存的问题

如果用AngularJs在IE下发出GET请求从后台服务取完Json数据再绑定到页面上显示的话,你可能会发现就算数据更新了,IE还是会显示原来的结果。实际上这时候IE的确是缓存了hashtag,没有再次去做Http GET请求最新的数据。 最直接的办法是在后台撸掉OutputCache,但这种做法并不推荐,需要改每一处被Angular调用的地方,代价太大。这种问题应该在前端解决最好。研究了一会儿总结了最有效的解决方法,并不需要改后台代码了。 在你的app config里撸一个$httpProvider进去,比如像我这样,和路由可以配在一起,当然分开配也没问题。 var config = ["$routeProvider", "$httpProvider", function ($routeProvider, $httpProvider) { // Initialize …

AJAX IE AngularJs

ASP.NET Web API接受JSON格式复杂对象(嵌套)

上礼拜在公司开荒Web API,被爆出翔了。遇到个具体问题是这样的:Web API中的方法接受的参数是个复杂对象,这个对象里嵌套了另一个对象。但使用API的人不知道如何在JSON里传递复杂对象给Web API。大家一起爆了很久,尝试了各种写法,还是没能解决。 今天我突然想到一个办法,可以获取正确的Nested JSON字符串。并且开荒成功了。与大家分享: 首先,我写的例子是这样的,Product对象里嵌套了一个Category对象,AddProduct的方法接受的是Product对象,我不仅需要Product的信息,也需要被嵌套的Category的信息: [HttpPost] public string AddProduct(Product productModel) { var sb = new StringBuilder(); sb.Append("Product. …

ASP.NET jQuery Json Web API

ASP.NET MVC3如何用JQuery传递数组(集合)类型参数给JsonResult Action

今天在码新版博客的一个功能,有个细节就是要将一个表格里选中的Id传给后台Action。原先用Form做Post的话,这是非常好实现的,然而现在我要用AJAX完成传递,并且网页上没有Form,所以我也不能用Ajax.BeginForm,肿么办呢?经过一番开荒,我终于把它码出来了。 后台Action是个返回JsonResult的方法,签名如下: public JsonResult ExportSelectedPosts(List selectedIds) 用string集合是因为手写AJAX是不走MVC的model bind的,所以通过网页传递过来的数据只能是string。如果这个方法不加selectedIds这个参数其实也是可以的(最后我们会看到用Request对象一样可以取到值)。但为了符合设计规范,我还是建议大家加上的。 前台的View里这样码(硬编码了一些数据只是为了演示): …

Array jQuery Json MVC