小编Rag*_*534的帖子

获得响应标题

使用Flurl从API获取响应.

var response = await url.WithClient(fc)
            .WithHeader("Authorization", requestDto.ApiKey)
            .GetJsonAsync<T>();
dynamic httpResponse = response.Result;
Run Code Online (Sandbox Code Playgroud)

但我无法访问httpResponse.Headers

如何在使用GetJsonAsync时访问响应标头.

c# .net-core flurl

6
推荐指数
1
解决办法
1909
查看次数

使用System.Net.Http.HttpClient时,服务器返回无效或无法识别的响应错误

最近我将我的代码库从.net core 1.0迁移到了2.0.之后,我收到错误"服务器在随机使用System.Net.Http.HttpClient时返回了无效或无法识别的响应错误".我在100个请求中的2个中收到此错误.

另外如何调试这个,因为它是随机发生的:(

Program.cs中

public class Program
    {
        public static void Main(string[] args)
        {
            var config = new ConfigurationBuilder()
            .AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(),"hosting.json"), optional: false)
            .Build();

            var useHttps = false;

            bool.TryParse(config !=null  ? config["useHttps"] : "false", out useHttps);

            IWebHost host = null;
            if (useHttps)
            {
                var fileInfo = new FileInfo(config["certName"]);
                X509Certificate2 cert = new X509Certificate2(fileInfo.FullName, config["certPwd"]);

                host = new WebHostBuilder()
                    .UseContentRoot(Directory.GetCurrentDirectory())
                    .UseStartup<Startup>()
                    .UseKestrel(options =>
                    {
                        options.Listen(IPAddress.Loopback, 5000);
                        options.Listen(IPAddress.Any, 4430, listenOptions =>
                        {
                            listenOptions.UseHttps(cert);
                        });
                    })
                    .UseIISIntegration()
                    .Build();
            } …
Run Code Online (Sandbox Code Playgroud)

httpclient kestrel kestrel-http-server asp.net-core-2.0 .net-core-2.0

6
推荐指数
1
解决办法
1317
查看次数

Okta API 分页下一个值是什么?

我使用 Okta 进行 SSO。我想列出所有 Okta 用户,但 API 的最大限制为 200。所以我需要在这里使用分页。

最初我使用了 URL

{{url}}/api/v1/users?limit=200
Run Code Online (Sandbox Code Playgroud)

不是,我收到了前 200 个用户的响应,以及响应标头中的下一个链接。下一个链接就像

{{url}}/api/v1/users?after=1uid&limit=200
Run Code Online (Sandbox Code Playgroud)

请看一下上面的after值。字符1已添加到最后一个用户 ID 的前面。这是为什么?

okta okta-api

3
推荐指数
1
解决办法
3806
查看次数

如何在数据库中进行左联接(Mongo)

我是Mongo的新手!请帮助我如何在Mongo中退出加入

Sql语句:

Select * from TableA left Join TableB 
on (TableA.col1 = TableB.col1 AND TableB.col2 = "ABC")
Run Code Online (Sandbox Code Playgroud)

请向我提供等效的Mongo查询!!!

提前致谢 !

mongodb mongodb-query aggregation-framework

1
推荐指数
1
解决办法
6109
查看次数