In this post I will explain what is HttpClientFactory and Polly retry policies and why you should use them in your next project.
dev.to/rickystam/net-core-use-httpclientfactory-and-polly-to-build-rock-solid-services-2edh
c# – Ignore XML namespace when modelbinding in asp net core web api
So, in order to be able to modelbind XML to a class without taking namespaces into consideration I created new InputFormatter. And I use XmlTextReader in order to ignore namespaces. Microsoft recommends to use XmlReader rather than XmlTextReader. But since XmlTextReader is there still (in .Net 6.0 Preview 3) I’ll use it for now.
Simply create an inputformatter that inherits from XmlSerializerInputFormatter like so:
public class XmlNoNameSpaceInputFormatter : XmlSerializerInputFormatter
{
private const string ContentType = "application/xml";
public XmlNoNameSpaceInputFormatter(MvcOptions options) : base(options)
{
SupportedMediaTypes.Add(ContentType);
}
public override bool CanRead(InputFormatterContext context)
{
var contentType = context.HttpContext.Request.ContentType;
return contentType.StartsWith(ContentType);
}
public override async Task<InputFormatterResult> ReadRequestBodyAsync(InputFormatterContext context)
{
var type = GetSerializableType(context.ModelType);
var request = context.HttpContext.Request;
using (var reader = new StreamReader(request.Body))
{
var content = await reader.ReadToEndAsync();
Stream s = new MemoryStream(Encoding.UTF8.GetBytes(content));
XmlTextReader rdr = new XmlTextReader(s);
rdr.Namespaces = false;
var serializer = new XmlSerializer(type);
var result = serializer.Deserialize(rdr);
return await InputFormatterResult.SuccessAsync(result);
}
}
}
Then add it to the inputformatters like so to startup.cs:
services.AddControllers(o =>
{
o.InputFormatters.Add(new XmlNoNameSpaceInputFormatter(o));
})
.AddXmlSerializerFormatters();
Now we can modelbind Person or any other class no matter if there is namespaces or not in the incoming XML. Thanks to @yiyi-you
Source: c# – Ignore XML namespace when modelbinding in asp net core web api – Stack Overflow
Advantages and Disadvantages of Microservices Architecture
Bulma: Free, open source, and modern CSS framework based on Flexbox
Bulma: the modern CSS framework that just works.
Bulma is a free, open source framework that provides ready-to-use frontend components that you can easily combine to build responsive web interfaces.
bulma.io/
Fine Code Coverage – Visual Studio Marketplace
Visualize unit test code coverage easily for free in Visual Studio Community Edition (and other editions too)
uptime-kuma: A fancy self-hosted monitoring tool
Monitoring uptime for HTTP(s) / TCP / Ping / DNS Record / Push. Fancy, Reactive, Fast UI/UX. Notifications via Telegram, Discord, Gotify, Slack, Pushover, Email (SMTP), and 70+ notification services, click here for the full list. 20 second intervals. Multi Languages Simple Status Page Ping Chart Certificate Info github.com/louislam/uptime-kuma
The Ultimate List of Every Known Command Prompt and PowerShell Command – MajorGeeks
The Ultimate List of Every Known Command Prompt and PowerShell Command
Command Prompt, sometimes referred to as CMD or even DOS is a command line interpreter built into Windows. It is mostly used to diagnose or troubleshoot problems in Windows. Most end users will never use these commands, but if the day ever comes, here is every command we know of, in alphabetical order.
Source: The Ultimate List of Every Known Command Prompt and PowerShell Command – MajorGeeks