.net-core

Can't figure out how to inject LinkGenerator

假装没事ソ 提交于 2021-01-28 11:02:14
问题 So I know how to setup my controller so that I can accept a LinkGenerator injected into the controller. What I can't figure out is how do I inject my controller at startup with a LinkGenerator. Controller protected readonly LinkGenerator _linkGenerator; public SomeController(config config, LinkGenerator linkGenerator) { config = Config; _linkGenerator = linkGenerator; } StartUp - ConfigureServices Controllers.SomeController someController = new Controllers.SomeController(config, linkGenerator

how to catch exit signal in asp.net core on linux?

两盒软妹~` 提交于 2021-01-28 10:43:00
问题 I am writing a c# console app base on net core 3.1 linux It was expected to run job async await job end catch the kill signal and do some clean job here is my demo code: namespace DeveloperHelper { public class Program { public static async Task Main(string[] args) { var http = new SimpleHttpServer(); var t = http.RunAsync(); Console.WriteLine("Now after http.RunAsync();"); AppDomain.CurrentDomain.UnhandledException += (s, e) => { var ex = (Exception)e.ExceptionObject; Console.WriteLine(ex

how to catch exit signal in asp.net core on linux?

橙三吉。 提交于 2021-01-28 10:37:04
问题 I am writing a c# console app base on net core 3.1 linux It was expected to run job async await job end catch the kill signal and do some clean job here is my demo code: namespace DeveloperHelper { public class Program { public static async Task Main(string[] args) { var http = new SimpleHttpServer(); var t = http.RunAsync(); Console.WriteLine("Now after http.RunAsync();"); AppDomain.CurrentDomain.UnhandledException += (s, e) => { var ex = (Exception)e.ExceptionObject; Console.WriteLine(ex

how to catch exit signal in asp.net core on linux?

怎甘沉沦 提交于 2021-01-28 10:35:02
问题 I am writing a c# console app base on net core 3.1 linux It was expected to run job async await job end catch the kill signal and do some clean job here is my demo code: namespace DeveloperHelper { public class Program { public static async Task Main(string[] args) { var http = new SimpleHttpServer(); var t = http.RunAsync(); Console.WriteLine("Now after http.RunAsync();"); AppDomain.CurrentDomain.UnhandledException += (s, e) => { var ex = (Exception)e.ExceptionObject; Console.WriteLine(ex

swagger add document and operation for a generic controller

断了今生、忘了曾经 提交于 2021-01-28 09:22:42
问题 i am working on a webapi with plugins. I want to update the swagger documentation when a plugin is added. I can handle this when i don't use version. All methods are added to the swagger documentation. but when the api has apiversion turned on, the generation of the new version swagger document failed. It returns a 404. do i need to so anything for versioning to work and pick up the dynamic controller functions... private string AddSwaggerVersionDocument(PluginMetadata metadata) { var version

Azure Pipelines counts xUnit InlineData as one test instead of many

ⅰ亾dé卋堺 提交于 2021-01-28 09:11:02
问题 In our Azure Pipelines pipeline we have .NET Core xUnit test methods that take an InlineData parameter. The test runner runs all test methods and correctly reports in its console output each InlineData instance as a test run. However, Azure Pipelines reports a lower test count because it counts the [Theory] tests as one test (instead of one test for every instance of InlineData). How can I make Azure Pipelines report all instances of InlineData as tests? As an example, here's a job output.

EF Core context not disposing of change tracking entities

和自甴很熟 提交于 2021-01-28 08:18:05
问题 Using EF Core 2.1 to insert 135k records. Once the request is finished, I would expect the context to be disposed of and along with it, the ChangeTracking entities to be cleared, however, it's holding on to all 135k records and using a lot of memory in the process. We are using ASP.NET Core 2.1 and injecting the EF Context from the DI container. Since the DI container should dispose of the scoped context at the end of the request, it should not be holding on to these values. Even calling

SignalR call from controller

心已入冬 提交于 2021-01-28 07:51:14
问题 I'm needing to pass strings from my controller to a signalR hub and have it render on my page. I've followed along with the chat tutorial found at: https://docs.microsoft.com/en-us/aspnet/core/tutorials/signalr?view=aspnetcore-2.2&tabs=visual-studio The next step from the chat tutorial is breaking it out message call to my controller like so: [HttpPost] public async Task<IActionResult> Upload(string engineType) { try { var message = "File Upload Failed"; await _errorHub.Clients.All.SendAsync(

How to update Azure Application Gateway Path Based Rule UrlPathMap from .NET

巧了我就是萌 提交于 2021-01-28 07:19:27
问题 On Azure Portal, I am able to setup path-based rules which have some default setting, and a list of sub-rules (UrlPathMap). Each of those sub-rules has a name, paths, backend pool, and HTTP setting that have to be configured. As I can see I can update this map easily through Azure Portal. I want to be able to create such sub-rules dynamically from code as part of the application installation. I would prefer to do this directly from .NET (ASP.NET Core 3.1) application, but Azure CLI or Azure

How do I use bouncy castle in .net to encrypt using RSA/ECB/OAEPWithSHA256AndMGF1Padding?

僤鯓⒐⒋嵵緔 提交于 2021-01-28 07:13:06
问题 There are examples on the web on how to use bouncy castle library in Java to encrypt with RSA/ECB/OAEPWithSHA256AndMGF1Padding (Example is shown at breaking down RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING). However the bouncy castle library in C# seem to have deviated from Java library in that it is more explicit (hence requires more steps) and I am not able to figure out how to make it work for the above algorithm. Would appreciate if some body can put a code sample together to encrypt a sample