【发布时间】:2011-12-22 21:58:31
【问题描述】:
在 asp.net 应用程序中,我有一个表单,在用户单击按钮后,我使用 Response.Redirect 转到另一个页面。但是在第二页中,Page_Load 事件没有触发。我尝试设置 AutoEventWireup="false。我还尝试清除浏览器的缓存,最后我尝试使用 this.Load 事件处理程序,但结果相同。感谢任何帮助。
提前致谢,圣诞快乐!
/添加代码/
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" %>
【问题讨论】:
-
你能告诉我们你重定向的代码和目标页面的directive吗?