.net-core

Configure JWT Bearer token validation using the public security key in .NET Core

元气小坏坏 提交于 2021-02-09 10:56:27
问题 My web application is a kind of wrapper for some 3rd party service. This 3rd party service uses the JWT Bearer authentication to access its WebAPI endpoints. The tokens are encrypted with RS256 algorithm (asymmetric). I have a Public Key to validate tokens signature on my side. It is easy to validate signature on jwt.io site (just paste the token and public key to the text boxes). But how do I configure TokenValidationParameters to have tokens validated automatically using specified Public

How to allow Caching API endpoint that requires Authorization header?

狂风中的少年 提交于 2021-02-09 10:51:39
问题 I was looking at a way for caching responses from an API endpoint developed in .NET Core. The request to the API must have a valid Authorization header as part the requirement. I came across a few articles mentioning that caching wouldn't be possible if the request contains Authorization header, which was a bit of surprise to me. So how should I tackle this problem? Are there any libraries that can possibly enable caching for this kind of scenario? 回答1: For The Authorization header must not

DotNetCore Capture A Screenshot in Windows

微笑、不失礼 提交于 2021-02-09 08:20:45
问题 I am looking to capture a screenshot using .NET core. I know that this is trivial using the .NET framework but is this possible using .NET core? I have searched but I can't find any answers anywhere. 回答1: System.Drawing.Common is available cross platform in .NET Core now allowing you to take screenshots of windows/your desktop. Here is an example EDIT An example capturing a screenshot: using var bitmap = new Bitmap(1920, 1080); using (var g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(0,

How to get class library assembly reference in .NET Core project?

三世轮回 提交于 2021-02-09 07:01:41
问题 I have an ASP.NET Core project (netcoreapp2.0) that references models in a class library project (netstandard2.0). I'm trying to use Mapster to map objects stored in the class library. The documentation for Mapster says to call the Scan method from Startup.cs using the code: TypeAdapterConfig.GlobalSettings.Scan(assembly1, assembly2, assemblyN) Where I'm having issues is how to best get the assembly reference for the class library to pass to the Scan method. I think this is more of a general

The library 'libhostpolicy.so' required to execute the application was not found

纵饮孤独 提交于 2021-02-08 21:17:32
问题 During running a dotnet console application I encountered this error. I ran it from a directory that had the .dll and .pdb file copied into it. What is the cause of this error? 回答1: the deps.json and runtimeconfig.json must also be copied into the directory that the .dll is invoked in. Without these files you will encounter this error. If you're doing post-build copies, make sure to include these files. 回答2: Please check chmod of application folder. When I change folder access mode, problem

The library 'libhostpolicy.so' required to execute the application was not found

若如初见. 提交于 2021-02-08 21:12:16
问题 During running a dotnet console application I encountered this error. I ran it from a directory that had the .dll and .pdb file copied into it. What is the cause of this error? 回答1: the deps.json and runtimeconfig.json must also be copied into the directory that the .dll is invoked in. Without these files you will encounter this error. If you're doing post-build copies, make sure to include these files. 回答2: Please check chmod of application folder. When I change folder access mode, problem

The library 'libhostpolicy.so' required to execute the application was not found

放肆的年华 提交于 2021-02-08 21:12:05
问题 During running a dotnet console application I encountered this error. I ran it from a directory that had the .dll and .pdb file copied into it. What is the cause of this error? 回答1: the deps.json and runtimeconfig.json must also be copied into the directory that the .dll is invoked in. Without these files you will encounter this error. If you're doing post-build copies, make sure to include these files. 回答2: Please check chmod of application folder. When I change folder access mode, problem

The library 'libhostpolicy.so' required to execute the application was not found

江枫思渺然 提交于 2021-02-08 21:07:07
问题 During running a dotnet console application I encountered this error. I ran it from a directory that had the .dll and .pdb file copied into it. What is the cause of this error? 回答1: the deps.json and runtimeconfig.json must also be copied into the directory that the .dll is invoked in. Without these files you will encounter this error. If you're doing post-build copies, make sure to include these files. 回答2: Please check chmod of application folder. When I change folder access mode, problem

Change in JSON generated for a System.Data.DataTable in a .NET Core project vs .NET Framework

余生长醉 提交于 2021-02-08 15:44:14
问题 The program below generates different JSON when run in a .NET Core project vs a .NET Framework app. Code class Program { internal static readonly MediaTypeFormatter DefaultFormatter = new JsonMediaTypeFormatter { UseDataContractJsonSerializer = false, SerializerSettings = { NullValueHandling = NullValueHandling.Ignore, DateTimeZoneHandling = DateTimeZoneHandling.Utc, DateFormatHandling = DateFormatHandling.IsoDateFormat } }; private static DataTable BuildTestDataTable() { var testDataTable =

Compile error with WPF .net Core 3.0 when adding .resx files

偶尔善良 提交于 2021-02-08 15:27:12
问题 Following works as expected: VS Studio 2019 tested with professional and community. Create new APF App (.NET Framework) Open properties Folder Change Resources.resx to public Create a new resources file (Resources.de.resx) Build Compiles as expected Following does not work: Create new APF App (.NET Core) Create a Resources Folder Create a new resources file (Resources.resx) Change it to public Create a new resources file (Resources.de.resx) Build Tested it on 3 different machines with VS 2019