如何将多个原点添加到webapi中的Timing-Allow-Origin customHeader

时间:2018-02-13 10:15:20

标签: c# http asp.net-web-api custom-headers

任何人都可以回答我的以下问题

  1. 我想通过c#代码为所有回复添加customHeaders。

  2. 使用c#

  3. 将多个来源添加到Timing-Allow-Origin customHeader

2 个答案:

答案 0 :(得分:0)

您可以像这样发送

const resize = (filepath: string, output: string, width: number = 256, height: number = 256) => {
  const proc = spawn("gm", ["convert", filepath, "-resize", `${width}x${height}`, output]);

  return new Promise((resolve, reject) => {
    let err = "";
    proc.stderr.on("data", chunk => {
      err += chunk.toString();
    });

    const onEnd = (code: number) => (code ? reject(err) : resolve());

    proc.on("close", onEnd);
    proc.on("end", onEnd);
  });
};

resize("C:/Users/Desktop/file.jpg", "C:/Users/Desktop/sfile.jpg");

答案 1 :(得分:0)

middleware插入管道:

app.Use(async (context, next) =>
{
    context.Response.Headers.Add("Time-Allow-Origin", new[] { "value1", "value2", "value3" });

    await next();
});