[英]Why Cors doesn't work after update to beta8 on ASP.NET 5?
I have updated ASP.NET 5 to beta8 and changed the dependency to "Microsoft.AspNet.Cors": "6.0.0-beta8". 我已将ASP.NET 5更新为beta8,并将依赖项更改为“Microsoft.AspNet.Cors”:“6.0.0-beta8”。
After that i get an error in ConfigureServices in line 之后,我在ConfigureServices中遇到错误
services.ConfigureCors(options => { options.AddPolicy("AllowAllOrigins", builder => builder.AllowAnyOrigin()); });
Error CS1929 'IServiceCollection' does not contain a definition for 'ConfigureCors' and the best extension method overload 'MvcCorsMvcCoreBuilderExtensions.ConfigureCors(IMvcCoreBuilder, Action)' requires a receiver of type 'IMvcCoreBuilder' WebAPI.DNX 4.5.1 C:...\\Startup.cs
错误CS1929'IServiceCollection'不包含'ConfigureCors'的定义,并且最佳扩展方法重载'MvcCorsMvcCoreBuilderExtensions.ConfigureCors(IMvcCoreBuilder,Action)'需要类型为'IMvcCoreBuilder'的接收器WebAPI.DNX 4.5.1 C:... \\ Startup.cs
How can i fix it and activate CORS? 我该如何解决它并激活CORS?
The name of the method has changed to AddCors
. 方法的名称已更改为
AddCors
。
So now you should use services.AddCors()
instead of services.ConfigureCors()
: 所以现在你应该使用
services.AddCors()
而不是services.ConfigureCors()
:
services.AddCors(options =>
{
options.AddPolicy("AllowAllOrigins", builder => builder.AllowAnyOrigin());
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.