天道酬勤,学无止境

.net-core-2.0

C# StreamContent and File.OpenRead() Not Producing HTTP'able multipart content

I have a .Net Core 2.0 application that is sending files to a Web API endpoint, using multipart content. Everywhere I've looked, such as C# HttpClient 4.5 multipart/form-data upload, makes it seem that it should be as easy as passing a FileStream to a StreamContent. However, when I make the post, it looks like the file is attaching as text, not bits. Actual code: var request = new HttpRequestMessage() { Method = HttpMethod.Post, RequestUri = new Uri( "http://localhost:10442/filetest" ) }; var multiContent = new MultipartFormDataContent(); var filestream = File.OpenRead( path ); var filename =

2021-09-08 07:17:07    分类:问答    c#   httpclient   .net-core-2.0

Use Certificate Revocation List file with X509 in .Net

Need to protect client-server communication. I was found a nice approach in .Net Core to generate X509 Certificates ( Self-Signed). But it's really lack of any information how to work with Certificate Revocation List in .Net Framework. Will be appreciate for answers to those questions : How to create CRL file with .Net ( Without BouncyCastle ) ? Can it be created as any text file and signed after? If yes, what is the format of columns? Is I'm right understanding that CRL file could be added to Certificate? As far as I know, a change of certificate brokes it. How to add Certificate to

2021-09-08 06:39:07    分类:问答    .net   x509certificate2   .net-core-2.0

Avoid logging twice using netcore2.0 on AWS Lambda with Serilog

After upgrading my netcore project to 2.0, i see double logs when my application is running on AWS Lambda, which utilizes the Serilog framework. Please see my setup below: public void ConfigureServices(IServiceCollection services) { ... // Setup logging Serilog.Debugging.SelfLog.Enable(Console.Error); var logger = new LoggerConfiguration() .MinimumLevel.Debug() .Enrich.FromLogContext(); if (GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT", "").Equals("local")) logger.WriteTo.Console(); else logger.WriteTo.Console(new JsonFormatter()); Log.Logger = logger.CreateLogger(); ... } and public void

2021-09-04 18:53:26    分类:问答    c#   amazon-web-services   lambda   serilog   .net-core-2.0

.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase is not working in .net core 2.1?

We are using the code below to send the custom message from server side to client side in HTTP request. It is working properly in .NET Core 2.0 Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase While using the same code in .NET Core 2.1 it does not work. It doesn't throw any script errors but we couldn't get message in client side success. How to resolve this problem?

2021-08-11 03:12:23    分类:问答    .net-core   .net-core-2.0   .net-core-2.1

How do I download a package from the command line with .NET Core from nuget?

Microsoft packages .NET Core on Linux for Ubuntu. I'm currently using that. I now want to install Json.NET which instructs me to use the Package Manager console and run, PM> Install-Package Newtonsoft.Json I'm wondering how I do that Linux. I see that there is a Nuget CLI, but it doesn't seem like that's available on .NET Core. Moreover the docs say On Mac and Linux, install Mono 4.4.2 or later. How do I simply install a package on Linux? What's the .NET equivalent of npm/cpan/pip/gem? When I run dotnet nuget, the install command seems to be missing. NuGet Command Line 4.3.0.5 Usage: dotnet

2021-08-01 05:44:28    分类:问答    c#   .net   linux   .net-core   .net-core-2.0

Missing extension method AddJwtBearerAuthentication() for IServiceCollection in .NET Core 2.0

I have updated my project from Core 1.1 to Core 2.0 using instructions from https://blogs.msdn.microsoft.com/webdev/2017/08/14/announcing-asp-net-core-2-0/ (updated target framework to .NET Core 2.0 and used metapackage Microsoft.AspNetCore.All). I have updated all possible nuget packages to latest versions as well. In .NET Core 1.1 i was adding JWT Bearer Authentication this way: app.UseJwtBearerAuthentication(); // from Startup.Configure() As per http://www.talkingdotnet.com/whats-new-in-asp-net-core-2-0/ for Core 2.0 the new way is to call: services.AddJwtBearerAuthentication(); // from

2021-07-28 09:24:46    分类:问答    authentication   jwt   bearer-token   .net-core-1.1   .net-core-2.0

Storing Azure Vault Client ID and Client Secret

I am using .NET Core 2.0 and ASP.NET Core 2.0 for application development. The "test" application is a .NET Core Console application. The core code I am writing is a class library. Once proper testing. I choose to do this since I won't be putting this to use for awhile (it's replacing older ASPNET code). Anyway, since I have to work with a LOT of API keys for various services I decided to use Microsoft Azure Key Vault for storing the keys. I have this all setup and understand how this works. The test application uses a test Azure account so it's not critical. And since this is replacing legacy

2021-07-13 17:38:02    分类:问答    .net-core   asp.net-core-2.0   azure-keyvault   .net-core-2.0

Problems with adding reference to netstandard 2.0

I changed my Asp.Net Core 1.1 application to Core 2.0 This went pretty well but after I updated my nuget packages and I get this error everywhere The type 'xxx' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. When I press the button to add an assembly nothing happens. I tried rebuilding and restoring my packages multiple times but it won't work

2021-07-11 19:15:46    分类:问答    c#   .net   .net-core   .net-core-2.0

VS 2017 and Docker: Operation aborted

.Net Core 2 came out, so I updated Visual Studio 2017 (Community) to release 15.3.0 (and subsequently 15.3.2) which has support for Docker which I've installed on my machine (Windows 10), and I believe I've configured things correctly. I created a basic Web API project—on .NET Core 2.0 without Docker—and that works. Now I add Docker support and I can't get it to run! I get the following error: How do I debug this? The only other Q&A I found wasn't helpful. If you recognize the error, do you know how to fix it?

2021-07-11 12:07:51    分类:问答    docker   windows-10   visual-studio-2017   .net-core-2.0

Sonarqube vsts task exception on coverage for .net core 2 app

I believe this is more a bug report than a support question, but may be i can workaround it. I am building & testing a .net core 2 app: the vstest step is configured as below: A trx file and a binary .coverage files are produced. If Code coverage checkbox is disabled, build works. If enabled like in the picture it fails with the following error: SonarQube Scanner for MSBuild 3.0.2 Default properties file was found at C:\agent\_work\_tasks\SonarQubeScannerMsBuildBegin_15b84ca1-b62f-4a2a-a403-89b77a063157\3.0.2\SonarQubeScannerMsBuild\SonarQube.Analysis.xml Loading analysis properties from C

2021-07-02 06:20:25    分类:问答    sonarqube   azure-devops   sonarqube-scan   asp.net-core-2.0   .net-core-2.0