|
@@ -6,12 +6,28 @@ namespace Vit.Extensions
|
|
public static partial class IServiceCollectionExtensions_AllowAnyOrigin
|
|
public static partial class IServiceCollectionExtensions_AllowAnyOrigin
|
|
{
|
|
{
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 允许跨域访问。(尽早调用)
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="services"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public static IServiceCollection AllowAnyOrigin(this IServiceCollection services )
|
|
|
|
+ {
|
|
|
|
+ AllowAnyOrigin_ConfigureServices(services);
|
|
|
|
+
|
|
|
|
+ services.ConfigureApp(AllowAnyOrigin_Configure);
|
|
|
|
+
|
|
|
|
+ return services;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
public static void AllowAnyOrigin_ConfigureServices(IServiceCollection services)
|
|
public static void AllowAnyOrigin_ConfigureServices(IServiceCollection services)
|
|
{
|
|
{
|
|
services.AddCors();
|
|
services.AddCors();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
public static void AllowAnyOrigin_Configure(IApplicationBuilder app)
|
|
public static void AllowAnyOrigin_Configure(IApplicationBuilder app)
|
|
{
|
|
{
|
|
//支持 net core 5.0及以上版本
|
|
//支持 net core 5.0及以上版本
|
|
@@ -25,22 +41,5 @@ namespace Vit.Extensions
|
|
.AllowCredentials());
|
|
.AllowCredentials());
|
|
}
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
|
- /// 允许跨域访问。(尽早调用)
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="services"></param>
|
|
|
|
- /// <returns></returns>
|
|
|
|
- public static IServiceCollection AllowAnyOrigin(this IServiceCollection services )
|
|
|
|
- {
|
|
|
|
- AllowAnyOrigin_ConfigureServices(services);
|
|
|
|
-
|
|
|
|
- services.ConfigureApp(AllowAnyOrigin_Configure);
|
|
|
|
-
|
|
|
|
- return services;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|