我試圖做一個HTTP 302重定向,但得到以下異常,而我在調試模式下運行。Http重定向302
Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack
var response = HttpContext.Current.Response;
response.Clear();
response.Status = "302 Found";
response.AddHeader("Location", "http://google.com");
response.End();
response.Flush();
長話短說,這個呼叫未沖洗的響應,而不是重定向。
我該如何得到這個工作?
您是否在調試模式下編譯您的應用程序並像這樣運行,或者您是否在發佈模式下編譯應用程序,並簡單地將調試程序附加到進程? – Icarus
看看這裏以及http://automagical.rationalmind.net/2010/03/08/response-redirect-and-302-and-301-status-codes/ –