I observe an exception executing the following code:
[<EntryPoint>]
let main argv =
WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.Configure(Action<IApplicationBuilder> configureApp)
.ConfigureServices(Action<IServiceCollection> configureServices)
.Build()
Error:
Unable to resolve service for type 'Microsoft.AspNetCore.Cors.Infrastructure.ICorsService
Details:
System.InvalidOperationException: 'Unable to resolve service for type 'Microsoft.AspNetCore.Cors.Infrastructure.ICorsService' while attempting to activate 'Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware'.'
I added the Cors code here:
let configureServices (services : IServiceCollection) =
...
services.AddAuthentication() |> ignore
services.AddCors |> ignore // Enables CORS
Note:
This all use to work until I added ASP.Net WebAPI support for some json that I was struggling with.
In addition, I also upgraded my Nuget packages to 2.0.
The source code can be found on GitHub.
You have to add services.AddCors()
in ConfigureServices(IServiceCollection services)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With