1
在基本控制器上使用RedirectPermanent(url)方法時,MVC3應用程序中出現此錯誤。緩衝由其他StackOverflow答案建議的輸出,沒有任何效果。發送HTTP頭後無法重定向MVC3
protected void Application_BeginRequest(object sender, EventArgs e)
{
Context.Response.BufferOutput = true;
}
重定向被觸發作爲本網站的默認控制器上的第一個行動的結果: http://www.autoquoter.com
我沒有直接將頭部的任何代碼。既然如此,有什麼方法可以確定什麼是添加響應頭?
以下是webkit調試器爲網站第一頁提供的網絡日誌。
Request URL:http://www.autoquoter.com/
Request Method:GET
Status Code:301 Moved Permanently
Request Headers
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2
Response Headers
Cache-Control:no-cache, no-store, must-revalidate
Content-Length:128
Content-Type:text/html; charset=utf-8
Date:Thu, 21 Mar 2013 17:10:38 GMT
Expires:-1
Location:/aq/en/Home
Pragma:no-cache
Server:Microsoft-IIS/6.0
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:3.0
X-Powered-By:ASP.NET