在我的项目中我有两个课程
public class Node
{
public int IdNode { get; set; }
public string Description { get; set; }
public int IdLocation { get; set; }
public int IdNearStation { get; set; }
public bool IsEnable { get; set; }
public bool IsRealSensor { get; set; }
public bool IsSprinklerON { get; set; }
public bool IsLightOn { get; set; }
Run Code Online (Sandbox Code Playgroud)
和这个
public class Node
{
public int IdNode { get; set; }
public string Description { get; set; } …Run Code Online (Sandbox Code Playgroud) 我试图检索在后端(Asp.net Core 2.2)中生成的 excel 文件的文件名,正如您在 c# 代码中看到的,文件名在响应的标头中检索,但从客户端我无法访问到标题“内容处理”
正如您在打印波纹管中看到的,尽管内容处置不存在于标题中,但它存在于 XHR 响应标题中
我已经在后端启用了 de CORS 策略,如下所示:
Startup.cs(ConfigureServices 方法)
services
.AddCors(options =>
{
options.AddPolicy(CorsAllowAllOrigins,
builder => builder.WithOrigins("*").WithHeaders("*").WithMethods("*"));
})
.AddMvc(options =>
{
options.Filters.Add(new AuthorizeFilter(authorizationPolicy));
})
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
var key = Encoding.ASCII.GetBytes(jwtSecurityOptions.SecretKey);
options.Audience = jwtSecurityOptions.Audience;
options.RequireHttpsMetadata = false;
options.SaveToken = true;
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuerSigningKey = true,
IssuerSigningKey = new SymmetricSecurityKey(key),
ValidateIssuer = false,
ValidateAudience = false
};
})
Run Code Online (Sandbox Code Playgroud)
Startup.cs(配置方法)
app.UseAuthentication();
app.UseCors(CorsAllowAllOrigins);
app.UseMvc();
Run Code Online (Sandbox Code Playgroud)
控制器
[HttpGet("{reportResultId}/exportExcelFile")]
[ProducesResponseType(StatusCodes.Status200OK)] …Run Code Online (Sandbox Code Playgroud)