zoukankan      html  css  js  c++  java
  • ABP问题集结

    1. 添加js跨域访问。

    在Startup.cs文件中  public IServiceProvider ConfigureServices(IServiceCollection services)中添加

     services.AddCors(
                    options => options.AddPolicy(
                        "AlloweDomain",
                        builder => builder
                            .WithOrigins(
                                // App:CorsOrigins in appsettings.json can contain more than one address separated by comma.
                                _appConfiguration["App:CorsOrigins"]
                                    .Split(",", StringSplitOptions.RemoveEmptyEntries)
                                    .Select(o => o.RemovePostFix("/"))
                                    .ToArray()
                            )
                            .AllowAnyHeader()
                            .AllowAnyMethod()
                            .AllowCredentials()
                    )
                );

    在允许跨域的Controller中添加。也可以在ControllerBase中添加允许全部继承继承类的Controller。

     [EnableCors("AlloweDomain")]
      public class FileGetController : ServiceControllerBase
    {
    
    }

    在appsettings.json添加允许访问的域名。

    "App": { 
        "CorsOrigins": "http://localhost:4200,http://localhost:8080,http://localhost:8081,https://www.baidu.com"
      },
  • 相关阅读:
    Django contenttypes组件
    Django admin组件使用
    Django 信号
    Django 中间件
    Django 分页组件替换自定义分页
    Django ORM操作补充
    Django ORM 操作2 增删改
    Django 序列化
    JavaScript
    CSS 属性
  • 原文地址:https://www.cnblogs.com/lecone/p/11097139.html
Copyright © 2011-2022 走看看