.net-core

Why does Curve25519 calculate key pair correctly even though its parameters are wrong?

半腔热情 提交于 2021-01-28 06:16:00
问题 It seems that .NET (Core 3.1) supports custom curves in ECC. So I've defined the Curve25519, and generated key pair by below code: using System; using System.Security.Cryptography; namespace Curve25519 { class Program { static void Main(string[] args) { ECCurve ecCurve = new ECCurve() // Curve25519, 32 bytes, 256 bit { CurveType = ECCurve.ECCurveType.PrimeMontgomery, B = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, A = new byte

Using StaticFileOptions() breaks embedded static files from Razor Class Library

风格不统一 提交于 2021-01-28 05:43:21
问题 I'm trying to add long cache headers to static .css and .js files using StaticFileOptions From various SO and other articles, this is how you do it: app.UseStaticFiles(new StaticFileOptions { OnPrepareResponse = ctx => { const int durationInSeconds = 60 * 60 * 24; ctx.Context.Response.Headers[HeaderNames.CacheControl] = "public,max-age=" + durationInSeconds; } }); However, I am using a bunch of static files provided by a RCL. The RCL has a StaticServing.cs class which I have used from this

What is the right string comparison value to be used in a machine to machine communication scenario?

我们两清 提交于 2021-01-28 05:33:03
问题 Consider a scenario where you are implementing code meant to be used for machine to machine communication. The typical example for that is the code executed inside a web API action method. Suppose that you want to perform an exact match between strings; maybe you have a list of users and you wan to find one specific user provided the user name: List<User> users = .... const string username = "user-123"; var user = users.Find(u => string.Equals(username, u.UserName)); In such a scneario should

ERR_CONNECTION_REFUSED - .Net Core 1.0.1

試著忘記壹切 提交于 2021-01-28 05:30:33
问题 Update : Even a new .net core web application is showing the same error. I'm using .Net Core Version 1.0.0-preview2-003131. I upgraded a .Net Core SDK from Version 1.0.0-preview2-003121 to the above mentioned. Now when I try to run the application I get the error: ERR_CONNECTION_REFUSED When I searched on Internet most of the stuff is to change the Port number. I change that and it still doesn't work. Any ideas how to fix this? The project.json file is: { "userSecretsId": "aspnet-Angle_MVC6

Graph API - adding Schema Extension using .Net Core 3.1

巧了我就是萌 提交于 2021-01-28 05:25:50
问题 I need to add custom claims to my Azure B2C users, so I figured the way to do this is to add schema extensions to the User for my directory App with Graph API (beta). I wrote a simple test for that: SchemaExtension schemaExtension = new SchemaExtension { Id = schemaName, Owner = _appClientId.ToString(), Description = string.IsNullOrWhiteSpace(schemaDesc) ? string.Empty : schemaDesc.Trim(), TargetTypes = new List<string> { "User" }, Properties = new List<ExtensionSchemaProperty> { new

Function with return type of 'string' returns a nullable string (ie 'string?')

与世无争的帅哥 提交于 2021-01-28 05:20:31
问题 For an Azure Functions project I am using C# 8 with enabled nullable reference types. Since with AzureFunctions AppSettings are exposed via environment variables, which can be a string or null (i.e. they return string? ) I tried to encapsulate the logic of getting environment variables - and throwing an error if they're not set - into a separate method GetEnvVariable . As you can see, GetEnvVariable is implemented in three short lines. If the environment variable is not set (i.e it is null )

Build a Generic Expression Tree .NET Core

二次信任 提交于 2021-01-28 05:16:59
问题 Hello Community i am aware of this might be a possible duplicate. How do I dynamically create an Expression<Func<MyClass, bool>> predicate from Expression<Func<MyClass, string>>? https://www.strathweb.com/2018/01/easy-way-to-create-a-c-lambda-expression-from-a-string-with-roslyn/ How to create a Expression.Lambda when a type is not known until runtime? Creating expression tree for accessing a Generic type's property There are obviously too many resources. I am still confused though. Could

what's the best solution for Many to Many Relation in .Net Core(EF Core)? [duplicate]

江枫思渺然 提交于 2021-01-28 05:16:46
问题 This question already has an answer here : Entity Framework Core many-to-many navigation issues (1 answer) Closed 10 months ago . as you know we don't have automatic Many to Many Relations between Entities in EF Core. whats the best solution to achieve that? here what I create for do that: class Student { public int StudentId { get; set; } public string Name { get; set; } public string Family { get; set; } public List<StudentCourse> Courses { get; set; } } class Course { public int CourseId {

Azure Pipeline Failing in dotnet build, need to upgrade to latest .net core version

白昼怎懂夜的黑 提交于 2021-01-28 05:14:13
问题 I'm having an issue with my deployment in my Azure Pipeline for my .Net Core API deployment. The build is failing because recently the API was upgraded from .Net Core 3.1 to .Net Core 5.0. How do I upgrade the version in the deployed API? The build is failing because of it. 2020-12-15T17:28:36.4659829Z Welcome to .NET Core 3.1! 2020-12-15T17:28:36.4663885Z --------------------- 2020-12-15T17:28:36.4664170Z SDK Version: 3.1.404 2020-12-15T17:28:36.4664326Z 2020-12-15T17:28:36.4664473Z

HttpContextAccessor.HttpContext.User.Identity..Name is empty in IIS working in VS2017

南楼画角 提交于 2021-01-28 05:11:08
问题 I have a .net core 2.2 web application where the Signin happens using the following code await _httpContextAccessor.HttpContext.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity), authProperties); The values of httpContextAccessor.httpContext.user.identity.name are retained properly for further requests and works in VS2017. But on deploying to server with IIS the same code doesnt work and the values for httpContextAccessor.User.Identity.Name is