尝试varios方法,而不是成功。 我想更改标题并在javascript中获取
结果debug,headers.Add 标题未知=我的标题授权
我无法在javascript中获取它,因为他没有发送标头,如何发送标头?
.net core web api 2.0
答案 0 :(得分:0)
解决!
solved! // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseMiddleware(typeof(ErrorHandlingMiddleware));
app.UseCors(b => b.AllowAnyHeader().WithExposedHeaders("Authorization").AllowAnyMethod().AllowAnyOrigin().AllowCredentials());
app.UseMvc();
}
添加.WithExposedHeaders(“授权”)
THX