.net-core

Passing List object and int to web api

大兔子大兔子 提交于 2021-01-28 22:47:46
问题 I have a web api core project that if I send just the list parameter than the API receives the values, however if I send both parameters that the controller is looking for then both parameters are seen as null My contoller: [HttpPost] [Route("/jobApi/RunBD")] public int RunBDReport([FromBody]int month, [FromBody] IEnumerable<ClientModel> clients) { billingDetailCycle objBillDetail = new billingDetailCycle(); if (ModelState.IsValid) { return objBillDetail.Run(clients.ToList(), month); } else {

AspNet Core Autofac disposing my DbContext even if its registered as SingleInstance

痞子三分冷 提交于 2021-01-28 21:18:55
问题 In our application, we have an api which will store some data to a database. We are using Entity Framework Core 3.1.1 . After this entity has been stored, a message is posted to Azure Servicebus and a consumer will read this message a store the message to another table in the same DbContext . As far as I understand, a LifetimeScope is defined per request to the api. The LifetimeScope will start when the api request hits the ApiController and finishes when the endpoint is done processing the

LDAP authentication problem in ASP.NET Core for restricted users (logon workstations) using Novell.Directory.Ldap.NETStandard2_0

最后都变了- 提交于 2021-01-28 21:01:53
问题 I use Novell.Directory.Ldap.NETStandard2_0 package to authenticate users from Active Directory and it works fine for most of users. using (var cn = new LdapConnection()) { cn.Connect(ldapOptions.Host, ldapOptions.Port); var userDn = username.IndexOf('@') < 0 ? username + $"@{ldapOptions.Domain}" : username; cn.Bind(userDn, password); if (cn.Bound) { result.Result = AuthResult.Succeed; result.Message = "Login Successful using LDAP: {0}."; } return result; } The problem is when we need to

LDAP authentication problem in ASP.NET Core for restricted users (logon workstations) using Novell.Directory.Ldap.NETStandard2_0

心不动则不痛 提交于 2021-01-28 20:32:02
问题 I use Novell.Directory.Ldap.NETStandard2_0 package to authenticate users from Active Directory and it works fine for most of users. using (var cn = new LdapConnection()) { cn.Connect(ldapOptions.Host, ldapOptions.Port); var userDn = username.IndexOf('@') < 0 ? username + $"@{ldapOptions.Domain}" : username; cn.Bind(userDn, password); if (cn.Bound) { result.Result = AuthResult.Succeed; result.Message = "Login Successful using LDAP: {0}."; } return result; } The problem is when we need to

How to set a default value from appsettings to a property on a API Model

时光总嘲笑我的痴心妄想 提交于 2021-01-28 20:31:44
问题 How can I set a default value to a property, reading it from my appsettings.json file, on a model that is instantiated by the .NET Core 3 framework? I've created a repo (a completely new .NET Core 3 project) where I try to illustrate the problem: https://github.com/NelsonPRSousa/dependency-injection-default-constructor API Action: [HttpGet] public IEnumerable<WeatherForecast> Get([FromQuery] FilteringRequestModel request) { var defaultType = request.Type; var rng = new Random(); return

CI cannot build .NET project, fails with: “Couldn't find a valid ICU package installed on the system…”

隐身守侯 提交于 2021-01-28 20:11:06
问题 I am working on having Jenkins build our legacy .NET 2.1 applications as part of streamlining our kubernetes deployments Therefore I have created a custom Jenkins agent based on the jenkins/jnlp-slave:latest-jdk11 docker image (https://github.com/jenkinsci/docker-jnlp-slave) which in turn is Debian 9 based, extended with the official .NET Core (unpacked the ZIP from https://dotnet.microsoft.com/download/dotnet-core/2.1 , Debian updates does not work well with our firewall), and for trivial

Making POST request from console app results in Error 403 - Access denied

戏子无情 提交于 2021-01-28 20:02:12
问题 I am trying to use the new IBKR Client Portal API. I have written a simple console program to access the API but it results in Error 403 - Access denied. If I try the same request from Postman it seems to be working. I tried using fiddler to see the request that console app sends but that results in a separate error. How can I diagnose this issue? using System; using System.Net.Http; using System.Threading.Tasks; namespace ConsoleApp2 { class Program { static async Task Main(string[] args) {

Multiple Values Contains with Dynamic Linq

萝らか妹 提交于 2021-01-28 19:44:49
问题 How to use Multiple value with Contain in Dynamic Linq. Expected With Normal Linq : using System; using System.Linq; public class Simple { public static void Main() { string[] names = { "Burke", "Laptop", "Computer", "Mobile", "Ahemed", "Sania", "Kungada", "David","United","Sinshia" }; string[] vars = {"i","a"}; var query = names.Where(i=> vars.Any(j=>i.Contains(j))).ToList(); Console.WriteLine(query.Count); } } Expected SQL SELECT * FROM User WHERE (NAME LIKE '%a%'OR NAME LIKE '%b%') Tried

xunit “could not load type” error

谁都会走 提交于 2021-01-28 19:44:17
问题 I inherited a project and the tests ran fine. Today, I created a new class, and xunit errors out when I try to use this class in a test. Both the test project and the app are targeting .NET Framework 4.6.1. I do clean and rebuild on the both the solution and the test project, but I still get the error. error: Could not load type 'MyNewClass' from assembly 'MyApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. project.json: "buildOptions": { "warningsAsErrors": true }, "testRunner":

.Net Plugin Architecture Not Working with Nuget

徘徊边缘 提交于 2021-01-28 18:59:28
问题 I have a .Net Core 3.1 console application that loads plugins. One of my plugins connects to Sqlite and so it has a Nuget dependency on Microsoft.Data.Sqlite. However, I'm getting a missing DLL exception from the console app when loading/running the plugin because the following path doesn't exist: MyConsoleApp\bin\x86\Debug\netcoreapp3.1\runtimes\win-x86\native\e_sqlite3.dll I also have an MsTest project which tests this Sqlite plugin project. It does not have the same problem. Apparently the