我观察到执行以下代码的异常:
[<EntryPoint>]
let main argv =
WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.Configure(Action<IApplicationBuilder> configureApp)
.ConfigureServices(Action<IServiceCollection> configureServices)
.Build()
Run Code Online (Sandbox Code Playgroud)
错误:
无法解析类型为'Microsoft.AspNetCore.Cors.Infrastructure.ICorsService的服务
细节:
System.InvalidOperationException:“在尝试激活“ Microsoft.AspNetCore.Cors.Infrastructure.CorsMiddleware”时,无法解析类型为“ Microsoft.AspNetCore.Cors.Infrastructure.ICorsService”的服务。
我在这里添加了Cors代码:
let configureServices (services : IServiceCollection) =
...
services.AddAuthentication() |> ignore
services.AddCors |> ignore // Enables CORS
Run Code Online (Sandbox Code Playgroud)
注意:
在我为苦苦挣扎的json添加ASP.Net WebAPI支持之前,所有这些都可以使用。
此外,我还将我的Nuget软件包升级到2.0。
可以在GitHub上找到源代码。
归档时间: |
|
查看次数: |
1798 次 |
最近记录: |