为什么一个Cors不更新后工作beta8 ASP.NET的5? [英] Why Cors doesn't work after update to beta8 on ASP.NET 5?
问题描述
我已经更新ASP.NET 5 beta8,改变了依赖于Microsoft.AspNet.Cors:6.0.0-beta8
。这之后,我在在线ConfigureServices得到一个错误
services.ConfigureCors(选项=> {options.AddPolicy(AllowAllOrigins,建设者= GT; builder.AllowAnyOrigin());});
错误CS1929'IServiceCollection'不包含一个定义
ConfigureCors'和最佳推广方法重载
MvcCorsMvcCoreBuilderExtensions.ConfigureCors(IMvcCoreBuilder,
动作)'需要类型的接收器
IMvcCoreBuilderWebAPI.DNX 4.5.1 C:\\ Startup.cs
块引用>我该如何解决并激活CORS?
解决方案该方法的名称已更改为
AddCors
。结果
所以,现在你应该使用services.AddCors()
而不是services.ConfigureCors()
:services.AddCors(选项=>
{
options.AddPolicy(AllowAllOrigins,建设者= GT; builder.AllowAnyOrigin());
});I have updated ASP.NET 5 to beta8 and changed the dependency to "Microsoft.AspNet.Cors": "6.0.0-beta8".
After that i get an error in ConfigureServices in line
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
How can i fix it and activate CORS?
解决方案The name of the method has changed to
AddCors
.
So now you should useservices.AddCors()
instead ofservices.ConfigureCors()
:services.AddCors(options => { options.AddPolicy("AllowAllOrigins", builder => builder.AllowAnyOrigin()); });
这篇关于为什么一个Cors不更新后工作beta8 ASP.NET的5?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!