Edi Wang

Microsoft MVP for Azure

Web Development HTML, JavaScript, CSS

Call API with Windows Authentication from Blazor Web Assembly

I was rewriting an old Angular application to Blazor Web Assembly a couple of days ago. The App is an internal tool, which uses a backend API that has Windows Authentication. However, when calling API from HttpClient that UseDefaultCredentials, Blazor will throw PlatformNotSupportedException. The majority of internet search so far tell you it's not possible. Really? Let's see how to make it work! …
.NET Web API Blazor

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

RMB capitalization converter in 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

JQuery搞定SyntaxHighlighter v3.x长代码自动换行

长代码换行是SyntaxHighlighter3.0版本之前的功能,但3.0之后就木了,本人认为主要猿因是gutter(代码行号指示器)的换行难做。因为3.x版是将代码行号和代码部分分开生成HTML的,猿来的老版本是在一起的。这样做是便于直接复制代码,而不会复制到行号上去。 很多人都在想办法让它实现换行,但都卡在代码行号的问题上。我关注这个问题已经差不多一年了,今天终于有了个比较漂亮的解决办法。 首先,强制给代码部分换行的CSS还是要写的: body .syntaxhighlighter .line { white-space: pre-wrap !important; } 这段CSS换行的前提是,pre标签的外边一定要有一个固定宽度的容器对象。比如一个600px宽度的div就可以。 然后,我们需要一段JQuery,用来计算被换行的代码显示在页面上的高度,然后赋值给它的
jQuery