从106.2.1升级到106.6.10后,请求返回401未经授权状态

时间:2019-10-10 18:14:46

标签: restsharp

详细信息

我有一个Web应用程序,它使用Restsharp从azure函数请求数据。我最近更新了 在106.2.1上后达到106.6.10。当它们在本地运行时,它们工作正常,当它们是两个单独的源(例如AppDev和FunctionDev环境)时,它将不再起作用。当我使用HttpClient时,我不再遇到此问题。直接从功能请求也同样可以正常工作。

WebApp:使用Angular模板的.Net-Core 2.1 MVC

功能:.Net Framework 4.6.1版本1

Webapp代码

[HttpPost]
        public async Task<IActionResult> Request([FromBody]Model model)
        {
            var restRequest = new RestRequest($"api/request");

            restRequest.AddHeader("Origin", Request.Host.Host);
            restRequest.AddJsonBody(model);

            _restClient.BaseUrl = new Uri(_config["endpoint"]);

            var response = await _restClient.ExecutePostTaskAsync<ReponseModel>(restRequest);
            if(response.StatusCode == HttpStatusCode.OK) {
                return Ok(response.Data);
            }
            else
            {
                return new StatusCodeResult((int)response.StatusCode);
            }
        }

预期行为

我在Web应用程序中调用了我的http函数。通话返回时,我得到200状态代码和Json数据

实际行为

我在Web应用程序中调用了我的http函数。通话返回时,我会收到401状态代码。该功能甚至没有注册它正在被调用

重现问题的步骤

  1. 启动Web应用程序(使用RestSharp)和Function App(http触发器)
  2. 如上面的代码所示,触发向Function App的Web应用程序请求

规格

  • 版本:Windows 10
  • 平台:Windows / Azure
  • 子系统:Azure(应用程序服务),Windows(.Net-Core MVC)/(。Net框架功能V1)

0 个答案:

没有答案