Not able to expose the custom headers from WebAPI to client

前端 未结 1 1066
情书的邮戳
情书的邮戳 2021-01-22 01:27

I have written a program to download the pdf, word or txt file returned by web api and it\'s working fine. On server side I have used WebApi and client side AngularJs. Now the p

相关标签:
1条回答
  • 2021-01-22 01:30

    After adding below lines has solved my problem.

    // Add a custom header for filename and expose it to be consumed by JavaScript.
    response.Content.Headers.Add("Filename", zipFileName);
    response.Content.Headers.Add("Access-Control-Expose-Headers", "Filename");
    

    So basically adding Access-Control-Expose-Headers helped me to expose the custom headers to client. For more information on this please follow this link

    0 讨论(0)
提交回复
热议问题