How do you enable CORS(Cross Origin Resource Sharing ) on ASP.NET Core Web API

Error Description:- XMLHttpRequest cannot load http://localhost:50913/api/values. Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:4200′ is therefore not allowed access. Use Case: Posting the data from Angular 4 form  http://localhost:4200  to ASP.NET Core Web… Read More

Create ASP.NET Core Project using .NET Core CLI (Command Line Interface)

dotnet new mvc –auth None –framework netcoreapp1.1 dotnet new mvc –framework netcoreapp1.1 dotnet new –help For restoring all the packages you would need to run  dotnet restore Building and running application type and run  dotnet run Templates                 Short Name      Language      Tags ———————————————————————- Console Application       console        … Read More

System.IO.FileLoadException: Could not load file or assembly ‘System.Diagnostics.DiagnosticSource, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference.

Solution:-  If you use .NET Core tools preview 2 (e.g., VS2015 Update 3), then everything works fine on both .NET Framework 4.5.1 and 4.6.1. If you use .NET Core tools preview 3 (e.g., VS2017RC), then it works fine on .NET Framework 4.5.1, but fails with… Read More

RuntimeIdentifier must be set for .NETFramework executables. Consider RuntimeIdentifier=win7-x86 or RuntimeIdentifier=win7-x64

Solution:- Edit .csproj file add <RuntimeIdentifier>win7-x86</RuntimeIdentifier>   <PropertyGroup> <TargetFramework>net451</TargetFramework> <TypeScriptCompileBlocked>true</TypeScriptCompileBlocked> <PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>     <RuntimeIdentifier>win7-x86</RuntimeIdentifier> </PropertyGroup>