Asp.net core 无法解析类型为';Microsoft.AspNetCore.Cors.Infrastructure.ICorsService
我观察到执行以下代码时出现异常:Asp.net core 无法解析类型为';Microsoft.AspNetCore.Cors.Infrastructure.ICorsService,asp.net-core,f#,Asp.net Core,F#,我观察到执行以下代码时出现异常: [<EntryPoint>] let main argv = WebHostBuilder() .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .Configure(Action<IApplicationB
[<EntryPoint>]
let main argv =
WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.Configure(Action<IApplicationBuilder> configureApp)
.ConfigureServices(Action<IServiceCollection> configureServices)
.Build()
注:
在我添加了ASP.NETWebAPI对一些json的支持之前,这些都是可以使用的
此外,我还将Nuget软件包升级到2.0
源代码可以在上找到。您必须在
ConfigureServices(IServiceCollection services)中添加services.AddCors()
,
我可能已关闭,但我看不到您在Startup.fs
中使用AddMvc
和UseMvc>的位置,该服务以前运行时没有您建议的行。您具体添加了什么“直到我添加ASP.NET WebAPI支持…”?WebAPI不存在于ASP.NET Core上,正如您所知。Microsoft.AspNet.WebAPI.Client Microsoft.AspNetCore.Mvc.WebApiCompatShim
let configureServices (services : IServiceCollection) =
...
services.AddAuthentication() |> ignore
services.AddCors |> ignore // Enables CORS