total :
#常見狀態碼:服務器處理請求的結果狀態
200 : 表示請求處理完成並完美返回;
302 : 表示請求需要進一步細化;
404 : 表示客戶訪問資源Not Found;
500 : 表示服務器端的資源發生錯誤;(服務器理解你的這次請求,但是它自身發生錯誤,無法正常處理請求)
A> 請求重定向( Location);
方式一:
/* 方式一 */ context.Response.StatusCode = 302; //跳轉到外部某一網址 //context.Response.RedirectLocation = "https://www.baidu.com"; //跳轉到網站內部某一網址 context.Response.RedirectLocation = "/index.html";
方式二:
/* 方式二 */ //跳轉到外部某一網址 //context.Response.Redirect("http://www.baidu.com"); //跳轉到網站內部某一網址 context.Response.Redirect("/index.html");
效果:瀏覽器請求網址1后,會再次發送一個請求2,請求的網址就是你設置的location

B> 定時刷新( refresh);
1> 本頁面,間隔刷新;
context.Response.Headers.Add("refresh", "1");//第二個參數是刷新的時間間隔,單位是秒
效果:瀏覽器每隔1秒刷新一次本頁面;
2> 定時幾秒之后,頁面跳轉到某一網址;
//定時3秒,3秒后跳轉到內部URL //context.Response.Headers.Add("refresh", "3;URL=/Index.html"); //定時3秒,3秒后跳轉到外部URL context.Response.Headers.Add("refresh", "3;URL=https://www.baidu.com");
用途:可以實現類似於,用戶登錄成功后,幾秒跳轉的效果;
C> 讓瀏覽器以下載方式打開資源;
//filename動態改變; context.Response.Headers.Add("Content-Disposition", "attachment;filename=abc.zip");
效果:彈框提醒文件保存;

