• About
  • Privacy Policy
  • Utilities
Darchuk.NET

.NET Core

ASP.NET Core 2.2 SignalR Server

July 12, 2019 by Robert 1 Comment

SignalR is a technology that allows you to write bi-directional communication between a server and a client.  This can lead to some pretty cool interactions, such as a live-updating dashboard on a website, or the ability to communicate requests to a server without building HTTP endpoints.  SignalR does a lot of heavy lifting behind the … [Read more…]

Posted in: .NET Core, ASP.NET, C#, SignalR, Web Development Tagged: .NET Core, ASP.NET, C#, Realtime, SignalR, Web Development

Creating a .zip file with .NET

July 5, 2019 by Robert Leave a Comment

For some reason I always thought that you needed to add a third party library to make a zip file in C#, but apparently you can do it easily with an API that already exists in the framework. via GIPHY ZipArchive All you need to do is create a file and associate the file stream … [Read more…]

Posted in: .NET Core, C# Tagged: .NET, C#, DotNet, Zip

ASP.NET Core Unit Testing – Setting the request body

June 28, 2019 by Robert Leave a Comment

Every now and again I find it necessary to set up the request body manually (as opposed to using the [FromBody] tag).  In the controller you can read from the request body easily enough: via GIPHY Testing How do you test this?  Normally I would just create a controller, call the method, and check the … [Read more…]

Posted in: .NET Core, ASP.NET, C#, MVC, Unit Testing, Web API, Web Development Tagged: ASP.NET, ASP.NET Core, Csharp, unit testing, Web Development

ASP.NET Core Web API–Returning a FileStream

May 31, 2019 by Robert 3 Comments

So I built a service that collects information, say, log information, and sends it down to a client.  This information is normally streamed right to a web browser via SignalR, but sometimes there is a lot of it, and scrolling through it on the web view can be quite a pain.  It would be nice … [Read more…]

Posted in: .NET Core, ASP.NET, C#, Web API, Web Development Tagged: ASP.NET, C#, File Download, Stream, WebAPI

Spoofing a C# Stopwatch

May 24, 2019 by Robert Leave a Comment

C# has a Stopwatch class that is pretty accurate at timing things.  In fact, it uses some low-level operating system stuff to make sure to get exact timings.  This means it can be more accurate than comparing two different DateTime.Now instances. via GIPHY I’ve found myself using the Stopwatch occasionally, but it always is kind … [Read more…]

Posted in: .NET Core, C#, Unit Testing Tagged: .NET, C#, Testing, unit testing

Autofac–Automatically registering generics via constructors

May 17, 2019 by Robert Leave a Comment

Recently I had a situation where I had a class and interface to make a generic service which would do something based on whatever type is provided.  (Obviously, it was not so contrived…) These would then get injected to other classes to be used as necessary: Which works fine… as long as you remember to … [Read more…]

Posted in: .NET Core, C#, Reflection Tagged: .NET, AutoFac, C#, Csharp, DependencyInjection, Generics, IoC, Reflection

Extending Autofac Modules

May 10, 2019 by Robert 1 Comment

Autofac is a popular dependency injection library that I like to use because they’ve done a lot of legwork to get things to work nicely in .NET Core – (some DI frameworks were not happy with Microsoft’s decision to make a public abstraction for their own DI library). Modules If you have a big solution … [Read more…]

Posted in: .NET Core, C# Tagged: .NET, AutoFac, C#, DependencyInjection, DI

ASP.NET Core 2–Enabling SignalR logging

April 19, 2019 by Robert 1 Comment

Sometimes you just need some logging to do a sanity check that things are actually working the way that you’re expecting. via GIPHY Here’s how to turn logging on in ASP.NET Core 2 for SignalR: I’ve had to look this up more than twice, and its not exactly easy to find in the Microsoft docs, … [Read more…]

Posted in: .NET Core, ASP.NET, C#, Debugging, SignalR Tagged: .NET Core, ASP.NET, C#, Logging, SignalR

Serializing XUnit test cases

April 12, 2019 by Robert Leave a Comment

XUnit has some cool stuff like Theory, which lets you write multiple test cases to run against the same test code.  This lets you test multiple paths with different inputs without having to write multiple tests.  This can save you a lot of time as you can cover a lot of ground with a single … [Read more…]

Posted in: .NET Core, C#, Unit Testing Tagged: C#, Csharp, IXunitSerializable, unit testing, XUnit

C# overwriting a static field with reflection

April 5, 2019 by Robert Leave a Comment

Imagine that you have a NuGet package containing a bunch of static strings.  These fields are intended to be used instead of magic strings, making it so anything that takes a dependency on this NuGet package will all be on the same page about these unique keys. Now suppose that these keys also represent the … [Read more…]

Posted in: .NET Core, C#, Reflection, Unit Testing Tagged: Csharp, Reflection, Static, Testing
« Previous 1 2 3 … 5 Next »

Recent Posts

  • Allowing trailing JSON commas in ASP.NET Core 3
  • YADNC3JSG–Yet Another .NET Core 3.0 JSON Serializer Gotcha
  • Logging in a .NET Core 3 SignalR client
  • .NET Core 3 unit testing project sdk
  • .NET Core 3.0 Upgrade–New JSON Serializer Gotchas

Recent Comments

  1. Robert on C# Setting Socket Keep-Alive
  2. Oliver Schramm on C# Setting Socket Keep-Alive
  3. John Anderson on Waiting for a keypress asynchronously in a C# console app
  4. Ronald Garlit on .NET Core 3 unit testing project sdk
  5. Ronald Garlit on .NET Core 3 unit testing project sdk

Copyright © 2025 Darchuk.NET.

Omega WordPress Theme by ThemeHall