一、在请求地方拦截未授权请求

      ①、获取请求状态码、退出并重启

            System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
            System.Net.Http.StringContent content = new System.Net.Http.StringContent("");
            var response= await client.PostAsync("{url}", content);
            if(response.StatusCode== System.Net.HttpStatusCode.Unauthorized)
            {
                MessageBox.Show("登录信息失效,请重新登录", "提示信息", MessageBoxButtons.OK);

                Application.Restart();
                //kill当前应用程序
                System.Diagnostics.Process.GetCurrentProcess().Kill();
            }

 

相关文章:

  • 2021-09-03
  • 2022-12-23
  • 2021-09-05
  • 2021-10-08
  • 2022-12-23
  • 2022-12-23
  • 2021-08-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-18
  • 2022-12-23
  • 2022-01-05
相关资源
相似解决方案