一、在请求地方拦截未授权请求
①、获取请求状态码、退出并重启
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(); }