In ASP.NET Core unit tests, if you want to mock HttpContext.Features.Get<SomeType>(), here's the trick. Problem I have my Error page code that will get exception detail infomation, to do that, I use HttpContext.Features.Get<IExceptionHandlerPathFeature>(). public void OnGet() { var requestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; var exceptionFeature = HttpContext.Features. …
Problem
In ASP.NET Core, when you use extension methods on UrlHelperExtensions class, it would be difficult to write Mock in unit test. Because Moq doesn't support mocking extension methods.
For example, the following code that I use in my blog is using Url.Page() method:
var callbackUrl = Url.Page("/Index", null, null, Request.Scheme);
But in my unit test, mocking like this will throw …
Starting from version 2.2, ASP.NET Core allow you to use the InProcess mode to improve performance under IIS. Rick Strahl has a detailed article on this. Three years have passed, and now ASP.NET Core has reached version 5.0, how the performance diffs between servers? Let's take a look together. Rick's Test Result In the original article, Rick Strahl tested the performance of ASP.NET Core 2.2 in …
Cats are very helpful for programming. But when we are not at home, how can we remotely watch the cat and let our friends watch it together? With Azure, this problem will be solved! Live broadcast equipment and software USB Camera In terms of hardware, we only need an ordinary USB camera. It is recommended to use a camera with auto focus and resolution above 1080p. The image sensor of the camera …
We typically use Application Request Routing (ARR) module to host a reverse proxy on IIS. Azure App Service is also using IIS as it's gateway, which should work for reverse proxy, but it won't work by default. Let's see how can we enable ARR on Azure App Service. The Experiment I have https://dropdatabase.run/ domain, and I want to reverse proxy https://996.icu/ under https://dropdatabase.run/996. …
In order to improve the page loading speed of my blog for US users, I deployed an App Service in West US region on Azure some time ago. Now I have 2 servers running my blog, East Asia and West US. In this post, I'm going to illustrate how to use Azure to load balancing these servers, so that users can get access to the closest server for their regions. Adding Identifier Tags Since the codes …
Azure users frequently need to transfer resources to a different resource group or subscription due to budget constraints. Once the transfer is complete, the associated Dashboard components typically become invalid. This usually necessitates manually deleting and rebuilding each dashboard card individually. Is there a quick and accurate method to repair the Dashboard in a single step?
Website developers and operation will inevitably encounter hackers. There are many fully automated hacking tools and scripts on the Internet that can scan your website for known security vulnerabilities and launch fully automated attacks in an attempt to seize control of the server. As a result, businesses often purchase web site application firewalls (WAFs) and deploy in front of the web server …
When it comes to measuring network speed, you might think of testing the Internet connection speed with the famous speedtest. But in fact, just testing the Internet connection speed is not reliable. In some scenarios, the final Internet speed is also affected by the your infrastructure like the connection to your ISP's server. Therefore, it is very important to know where your network performance …