一、在请求地方拦截未授权请求
①、获取请求状态码、退出并重启
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();
// 或以进程方式启动【Restart(会以原参数方式启动),本方式默认无参启动】
System.Diagnostics.Process.Start(Application.ExecutablePath);
//kill当前应用程序
System.Diagnostics.Process.GetCurrentProcess().Kill();
}