【问题标题】:can't get "location" from response headers C#无法从响应标头 C# 中获取“位置”
【发布时间】:2023-01-12 19:04:45
【问题描述】:

enter image description here 位置上有一个令牌,我想得到

我试过这段代码

        Uri uri = new Uri(url);
        var handler = new HttpClientHandler
        {
            AllowAutoRedirect = false
        };
        HttpClient httpclient = new HttpClient(handler);
        client.DefaultRequestHeaders.Referrer = uri;
        var responsee = httpclient.GetAsync(uri).Result;
        var location = responsee.Headers.GetValues("location").FirstOrDefault();

但我只有 12 个标题键

enter image description here

我怎样才能得到位置键?

【问题讨论】:

    标签: c# response-headers


    【解决方案1】:

    使用 c# .net 7.0 你有一个 Location 属性,你可以像这样访问

    var location = responsee.Headers.Location;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-02
      • 2014-02-26
      • 1970-01-01
      • 2013-04-06
      相关资源
      最近更新 更多