.net-core-2.1

Using Always Encrypted of SQL Server from .NET Core 2.1

橙三吉。 提交于 2019-12-11 02:48:50
问题 I am aware that Microsoft has not specified any plan to support Always Encrypted from within Core, yet. However, this is supported by classical .NET Framework (4.5 onward). Our Core 2.1 project's usage of Always Encrypted is limited to two simple queries and we are willing to take alternative routes to use it other than downgrading from Core 2.1. There are many remote ways to solve these problems but they involve remoting (WCF or REST for another classical .NET) or through a Service Fabric

.net core get user in ValidationAttribute

白昼怎懂夜的黑 提交于 2019-12-10 10:43:33
问题 I am trying to access the current user (i.e. ClaimsPrincipal from identity) in a custom ValidationAttribute, and I haven't figured out how I could do that. public class UniqueTitleValidator : ValidationAttribute { protected override ValidationResult IsValid(object value, ValidationContext validationContext) { // var user = ? } } I know that I could access the user from a HttpContext (but I don't know how to get to the latter). The main problem is that I don't have access to the User. When I

Blazor, ASP.NET Core Hosted vs Server Side in ASP.NET Core

我怕爱的太早我们不能终老 提交于 2019-12-09 14:16:34
问题 I am trying my hands on blazor.Net which is an experimental framework. I already developed a small project in this Framework and its awesome. But after recent update in Blazor Language Service on 14 November I Am seeing owo options in Template selection. First is Blazor (ASP.NET Core Hosted) Second is Blazor (Server Side in ASP.NET Core) There is no information about difference between them, Can anybody tell me what is difference between these two templates and when should choose which one?

.NET Core X509Certificate2 usage (under Windows/IIS, Docker, Linux)

╄→гoц情女王★ 提交于 2019-12-08 17:01:45
问题 I am really trying a long time to use certificates in .NET Core API. Basically where I need to use them is in a .NET Core web api running on IIS and docker. Certificates I need to use are for: Microsoft.AspNetCore.DataProtection public void ConfigureServices(IServiceCollection services) { services.AddDataProtection() .PersistKeysToFileSystem(new DirectoryInfo(dataProtectionKeystorePath)) .ProtectKeysWithCertificate ( new X509Certificate2(dataProtectionCertificatePath,

Access ModelState in Asp.net core Middleware

℡╲_俬逩灬. 提交于 2019-12-08 00:40:50
问题 I need to access ModelState in Asp.net Core 2.1 Middleware, but this is just accessible from Controller . For example I have ResponseFormatterMiddleware and in this Middleware I need to ignore ModelState error and show it's errors in 'Response Message': public class ResponseFormatterMiddleware { private readonly RequestDelegate _next; private readonly ILogger<ResponseFormatterMiddleware> _logger; public ResponseFormatterMiddleware(RequestDelegate next, ILoggerFactory loggerFactory) { _next =

Re-target .NET Core to net471, net 472

主宰稳场 提交于 2019-12-06 21:40:26
问题 My .Netcore 2.0 project can target net471 . But when I upgraded to .NET 2.1, I can't retarget net471 or net472 Can I retarget in the latest version of .the NET core? Severity Code Description Project File Line Suppression State Error NU1202 Package Microsoft.AspNetCore.App 2.1.0 is not compatible with net471 (.NETFramework,Version=v4.7.1). Package Microsoft.AspNetCore.App 2.1.0 supports: netcoreapp2.1 (.NETCoreApp,Version=v2.1) and Severity Code Description Project File Line Suppression State

.net core get user in ValidationAttribute

核能气质少年 提交于 2019-12-06 09:12:47
I am trying to access the current user (i.e. ClaimsPrincipal from identity) in a custom ValidationAttribute, and I haven't figured out how I could do that. public class UniqueTitleValidator : ValidationAttribute { protected override ValidationResult IsValid(object value, ValidationContext validationContext) { // var user = ? } } I know that I could access the user from a HttpContext (but I don't know how to get to the latter). The main problem is that I don't have access to the User. When I use a custom ValidatorAttribute on a property, when the property gets constructed the User (or also

Re-target .NET Core to net471, net 472

ε祈祈猫儿з 提交于 2019-12-05 02:01:08
My .Netcore 2.0 project can target net471 . But when I upgraded to .NET 2.1, I can't retarget net471 or net472 Can I retarget in the latest version of .the NET core? Severity Code Description Project File Line Suppression State Error NU1202 Package Microsoft.AspNetCore.App 2.1.0 is not compatible with net471 (.NETFramework,Version=v4.7.1). Package Microsoft.AspNetCore.App 2.1.0 supports: netcoreapp2.1 (.NETCoreApp,Version=v2.1) and Severity Code Description Project File Line Suppression State Error NU1202 Package Microsoft.AspNetCore.App 2.1.0 is not compatible with net472 (.NETFramework

CORS error when adding Azure AD authentication

时光怂恿深爱的人放手 提交于 2019-12-05 00:33:25
问题 Trying to add Azure AD authentication to an Angular 7 webapp with a .net core 2.1 backend. However, I get the CORS error during the request. "Access to XMLHttpRequest at 'https://login.microsoftonline.com/.......' (redirected from 'https://localhost:5001/api/auth/login') from origin 'https://localhost:5001' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource." So I tried adding some CORS policy in the startup pipe-line. Startup.cs

How to use HttpClientHandler with HttpClientFactory in .NET Core

房东的猫 提交于 2019-12-04 01:31:26
I want to use the HttpClientFactory that is available in .NET Core 2.1 but I also want to use the HttpClientHandler to utilize the AutomaticDecompression property when creating HttpClients . I am struggling because the .AddHttpMessageHandler<> takes a DelegatingHandler not a HttpClientHandler . Does anyone know how to get this to work? Thanks, Jim Actually I'm not using automatic decompression but the way to achieve this is to properly register http client services.AddHttpClient<MyCustomHttpClient>() .ConfigureHttpMessageHandlerBuilder((c) => new HttpClientHandler() { AutomaticDecompression =