在asp.net應用程序中,我有一個表單,並且在用戶單擊按鈕後,我使用Response.Redirect轉到另一個頁面。但在第二頁中,Page_Load事件不會觸發。我試圖設置AutoEventWireup =「false。我也嘗試清除瀏覽器的緩存,最後我試圖使用this.Load事件處理程序,但結果是一樣的。推進和聖誕快樂!Page_Load沒有在ASP.NET中的Response.Redirect之後觸發ASP.NET
/添加的代碼/
protected void btnSubmit_Click(object sender, EventArgs e)
{
CreateXML();
PostToWebApplicationB();
Response.Redirect(url);
}
/這是PostToWebApplicationB方法/
private void PostToWebApplicationB()
{
try
{
request = WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "text/xml";
StreamWriter writer = new StreamWriter(request.GetRequestStream());
writer.WriteLine(this.GetTextFromXmlFile(filepath));
writer.Close();
response = request.GetResponse();
}
catch (Exception ex)
{
errorLabel.Text = ex.Message;
}
finally
{
if (request != null)
{
request.GetRequestStream().Close();
}
if (response != null)
{
response.GetResponseStream().Close();
}
}
}
/指令目標頁/
<%@ Page Language="C#" AutoEventWireup="false" CodeBehind="Intermediate.aspx.cs"
Inherits="WebApplicationB.Intermediate" %>
你能告訴我們你重定向代碼和[指令](http://msdn.microsoft.com/en-us/library/ydy4x04a.aspx)的目標網頁? – 2011-12-22 22:08:42
剛剛添加了代碼 – 2011-12-22 22:19:38
爲什麼不''Server.Transfer'? – 2011-12-22 22:28:25