.net-core

How to override MassTransit default exchange and queue topology convention?

佐手、 提交于 2021-02-07 20:54:52
问题 As pointed out [in one of my questions on SO] (Why a simple configuration in MassTransit creates 2 queues and 3 exchanges?), MassTransit for RabbitMQ creates automatically a certain number of queues and exchange for a given simple configuration: Exchanges, all fanouts: ConsoleApp1:Program-YourMessage : Durable VP0003748_dotnet_bus_6n9oyyfzxhyx9ybobdmpj8qeyt : Auto-delete and Durable? test_queue : Durable Queues: VP0003748_dotnet_bus_6n9oyyfzxhyx9ybobdmpj8qeyt : x-expire 60000 test_queue :

How to override MassTransit default exchange and queue topology convention?

只谈情不闲聊 提交于 2021-02-07 20:53:06
问题 As pointed out [in one of my questions on SO] (Why a simple configuration in MassTransit creates 2 queues and 3 exchanges?), MassTransit for RabbitMQ creates automatically a certain number of queues and exchange for a given simple configuration: Exchanges, all fanouts: ConsoleApp1:Program-YourMessage : Durable VP0003748_dotnet_bus_6n9oyyfzxhyx9ybobdmpj8qeyt : Auto-delete and Durable? test_queue : Durable Queues: VP0003748_dotnet_bus_6n9oyyfzxhyx9ybobdmpj8qeyt : x-expire 60000 test_queue :

.NET Core override controller level Authorize attribute for a specific action

≯℡__Kan透↙ 提交于 2021-02-07 20:43:04
问题 Here is an example controller to explain the case [Authorize] public class AccountController : ControllerBase { [AllowAnonymous] [Authorize(Policy = "SpecificPolicy")] public string MethodA() {} public string MethodB() {} } MethodA should only be authorized via "SpecificPolicy". MethodB should be authorized via the Authorized attribute The issue I'm having is that if I remove the AllowAnonymous attribute then Authorize on the controller takes precedence which I don't want for MethodA. When I

.NET Core override controller level Authorize attribute for a specific action

 ̄綄美尐妖づ 提交于 2021-02-07 20:42:38
问题 Here is an example controller to explain the case [Authorize] public class AccountController : ControllerBase { [AllowAnonymous] [Authorize(Policy = "SpecificPolicy")] public string MethodA() {} public string MethodB() {} } MethodA should only be authorized via "SpecificPolicy". MethodB should be authorized via the Authorized attribute The issue I'm having is that if I remove the AllowAnonymous attribute then Authorize on the controller takes precedence which I don't want for MethodA. When I

.NET Core - Globalization and Localization - Class library

假装没事ソ 提交于 2021-02-07 19:42:24
问题 Following this documentation on how to implement globalization and localization using .NET Core, my goal is to store all my resources in a single global resource file located in a different project, (class library). Project 1 - Startup.cs public class Startup { public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName

Cannot resolve scoped service

本小妞迷上赌 提交于 2021-02-07 18:26:25
问题 I have problem with understanding source of errors in my code. I try to get throw course about microservices in .net core. After running build solution I get: ------- Project finished: CrossX.Services.Identity. Succeeded: True. Errors: 0. Warnings: 0 But when I run it I get: /opt/dotnet/dotnet /RiderProjects/crossx/src/CrossX.Services.Identity/bin/Debug/netcoreapp2.2/CrossX.Services.Identity.dll Unhandled Exception: System.InvalidOperationException: Cannot resolve scoped service 'CrossX

How does ASP.NET Core determine MIME types and apply different middleware?

依然范特西╮ 提交于 2021-02-07 14:23:14
问题 I use ASP.NET Core MVC and .NET Core 2.0. I have some static files, they have different file types, JPEG, PNG, BMP ... I would like to apply different middleware according to different file types. Such as PNG file I will use ImageCompressMiddleware, BMP file I will use ImageConvertMiddleware. How does ASP.NET Core determine MIME types and apply different middleware? Or according to the file extension. 回答1: Create a FileExtensionContentTypeProvider object in configure section and fill or

How does ASP.NET Core determine MIME types and apply different middleware?

十年热恋 提交于 2021-02-07 14:21:51
问题 I use ASP.NET Core MVC and .NET Core 2.0. I have some static files, they have different file types, JPEG, PNG, BMP ... I would like to apply different middleware according to different file types. Such as PNG file I will use ImageCompressMiddleware, BMP file I will use ImageConvertMiddleware. How does ASP.NET Core determine MIME types and apply different middleware? Or according to the file extension. 回答1: Create a FileExtensionContentTypeProvider object in configure section and fill or

dotnet core in macOS: “The type initializer for 'Crypto' threw an exception”

╄→гoц情女王★ 提交于 2021-02-07 13:43:59
问题 I followed the instructions on the .NET Core website, but got this error. Apparently there are some pre-reqs which are missing. Any idea how to install those? mymac:~ naveen.vijay$ dotnet new Unhandled Exception: System.TypeInitializationException: The type initializer for 'Crypto' threw an exception. ---> System.TypeInitializationException: The type initializer for 'CryptoInitializer' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'System.Security.Cryptography

How to deserialize stream to object using System.Text.Json APIs

南笙酒味 提交于 2021-02-07 12:52:50
问题 I'm receiving a response from a web api call as a stream and need to deserialize it to a model. This is a generic method, so I can't say which parts of code will use this and what's the response payload. Here's the method: public async Task<T> InvokeAsync<T>(string method) { Stream response = await this.httpClientWrapper.InvokeAsync(method); var serializer = new JsonSerializer(); using var streamReader = new StreamReader(response); using var reader = new JsonTextReader(streamReader); return