How to mock IOptionsSnapshot instance for testing

You should be able to mock up the interface and create an instance of the options class for the test. As I am unaware of the nested classes for the options class I am making a broad assumption. Documentation: IOptionsSnapshot //Arrange //Instantiate options and nested classes //making assumptions here about nested types var options = … Read more

ASP.NET Core 1.1 compiling with C# dynamic Missing compiler required member ‘Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create’

I faced this problem. I resolved this problem for me. You must install Microsoft.CSharp library to your solution from nuget. You can use Package Manager Console for install Microsoft.CSharp. For example If you want install Microsoft.CSharp 4.7.0 version, you must run this command on the Package Manager Console: Install-Package Microsoft.CSharp -Version 4.7.0 Nuget link: Microsoft.CSharp

connection string for sqlserver in Docker container

sudo docker pull microsoft/mssql-server-linux:2017-latest docker run \ -e ‘ACCEPT_EULA=Y’ \ -e ‘MSSQL_SA_PASSWORD=YourSTRONG!Passw0rd’ \ -p 1401:1433 \ -n sql1 \ -d microsoft/mssql-server-linux:2017-latest then, private static string _connStr = @” Server=127.0.0.1,1401; Database=Master; User Id=SA; Password=YourSTRONG!Passw0rd”;

Error CS0234: The type or namespace name ‘AspNetCore’ does not exist in the namespace ‘Microsoft’ (are you missing an assembly reference?)

We just had this issue where visual studio helpfully added a local reference rather than going via nuget <ItemGroup> <Reference Include=”Microsoft.AspNetCore.Mvc.Core”> <HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.core\2.0.0\lib\netstandard2.0\Microsoft.AspNetCore.Mvc.Core.dll</HintPath> </Reference> </ItemGroup> Removing this and referencing via nuget solved the problem, looks like an issue in Visual Studio 2017.

How do I get current user in .NET Core Web API (from JWT Token)

The accepted answer did not work for me. I’m not sure if that’s caused by me using .NET Core 2.0 or by something else, but it looks like the framework maps the Subject Claim to a NameIdentifier claim. So, the following worked for me: string userId = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; Note that this assumes the Subject sub … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)