.net-core

Getting error with aspnet core 2.1 action filter due to missing suitable constructor

◇◆丶佛笑我妖孽 提交于 2021-02-11 13:37:35
问题 I have made a claims filter public class ClaimRequirementAttribute : TypeFilterAttribute { public ClaimRequirementAttribute(string claimType, ClaimRoles claimValue) : base(typeof(ClaimRequirementFilter)) { Arguments = new object[] {new Claim(claimType, claimValue.ToString()) }; } } public class ClaimRequirementFilter : IAuthorizationFilter { public void OnAuthorization(AuthorizationFilterContext context) { var headers = context.HttpContext.Request.Headers; var tokenSuccess = headers

Azure Linux App Service with .Net Core Stack. Unable to use NodeJS

和自甴很熟 提交于 2021-02-11 13:21:29
问题 I am hosting a .NET Core Application on MS Azure (on a Linux Service Plan) and I want to run some NodeJS code in the .NET Core Application. I did this a while ago on a Windows Service Plan, there it was working. Now I am trying with a Linux Plan and it is not working. First I was trying to use "Jering.Javascript.NodeJS" and then also "INodeServices" from Microsoft (which is obsolete). But "node" was not found. I also tried to start directly a Process (Code below), but also not working. "node"

C# Validate that generic type extends generic abstract class with type parameters

*爱你&永不变心* 提交于 2021-02-11 12:57:11
问题 I've am stuck and I'm looking for some clarification. I'm having an issue with reflection, I have a WPF app and I've implemented a plugin system as documented here: https://docs.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support However, I've modified and extended this a bit where my plugins extend an Abstract class instead of an Interface directly because I have some stuff in the constructor. On my project, the overall structure is the following: public abstract class

Newtonsoft JsonConvert datetime format as JavascriptSerializer

爷,独闯天下 提交于 2021-02-11 12:28:44
问题 I'm using .NET Core and want to serialize a date into the same format as the System.Web.Script.JavascriptSerializer, but using Newtonsoft jsonconverter instead (or something else compatible with .NET Core since the JavascriptSerializer is .NET framework). Example: DateTime result1; var dt1 = DateTime.TryParse("12.06.2012 10:34:00",CultureInfo.GetCultureInfo("DA-dk"), DateTimeStyles.None, out result1); JsonConvert.Serialize(result1); This does NOT return a format like this that I need: "/Date

Where do I find TestContext.AddResultFile()?

自闭症网瘾萝莉.ら 提交于 2021-02-11 08:19:31
问题 I am having trouble referencing the documented method AddResultFile() on the TestContext class, allegedly found in the Microsoft.VisualStudio.TestTools.UnitTesting package/namespace. This is my package list: <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" /> <PackageReference Include="Selenium.Support" Version="3.141.0" /> <PackageReference Include="Selenium.WebDriver" Version="3.141.0" /> <PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="2.46.0" />

Where do I find TestContext.AddResultFile()?

别说谁变了你拦得住时间么 提交于 2021-02-11 08:19:21
问题 I am having trouble referencing the documented method AddResultFile() on the TestContext class, allegedly found in the Microsoft.VisualStudio.TestTools.UnitTesting package/namespace. This is my package list: <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" /> <PackageReference Include="Selenium.Support" Version="3.141.0" /> <PackageReference Include="Selenium.WebDriver" Version="3.141.0" /> <PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="2.46.0" />

Where do I find TestContext.AddResultFile()?

夙愿已清 提交于 2021-02-11 08:18:05
问题 I am having trouble referencing the documented method AddResultFile() on the TestContext class, allegedly found in the Microsoft.VisualStudio.TestTools.UnitTesting package/namespace. This is my package list: <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" /> <PackageReference Include="Selenium.Support" Version="3.141.0" /> <PackageReference Include="Selenium.WebDriver" Version="3.141.0" /> <PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="2.46.0" />

Calling thirdparty container with .net core TestHost/TestServer via SSL: Bypass SSL Validation using Testservers CreateClient() method

别等时光非礼了梦想. 提交于 2021-02-11 08:02:20
问题 I am trying to add keycloak as a testcontainer to my .net core (5) integration tests using the dotnet-testcontainers library . My Problem is, I am struggling with HTTPS-Support having a container using self-signed certificates and TestServer-Class for my integration tests. To be precise, I am using Microsofts TestServer class to create real API requests with an in-memory config for using a keycloak-testcontainer with exposed port 8443 and its self-signed certificate. The Problem is: I can’t

Identity with ASP.Net Core 3.1 - on not authenticated, the app is not redirecting to Login in production like it does in dev

夙愿已清 提交于 2021-02-11 06:16:43
问题 I have an ASP.Net Core (3.1) web app that takes advantage of Identity. It works as desired on my dev box, but does not redirect to login in production. Let me explain. I have a home/landing page with links to actions all over it. If a user clicks on an action that requires Authentication (I am using the [Authorize] tag to specify that in my controller), then the app should redirect to the Login page to allow the user to login first and then redirect to the desired action that they click. This

EF Core always create .Annotation(“SqlServer:Identity”, “1, 1”) on add-migration

主宰稳场 提交于 2021-02-11 06:16:33
问题 I'm having a problem with Migration EF Core. To make the scenario clear, I'm assigning it to an existing database, which is intended to use migration for database control from now on. But I am having difficulties. What I have done so far. I generated the scaffolding from the existing database. I added the migration, so it generated all the "Up" for database creation. In a clean database, ran update-database. So far perfect, everything worked as expected. But from this step every time I