【发布时间】:2011-08-18 21:13:46
【问题描述】:
看看我下面的代码,我的问题很明显,如何在不重定向的情况下调用ashx文件?我需要按此顺序执行代码,但是当页面重定向时,重定向下方的所有内容都不会执行。提前致谢。
protected void btnAddMach_Click(object sender, EventArgs e)
{
InsertMachine();
if (cbMachIcal.Checked && !cbMachGcal.Checked)
{
Response.Redirect("iCal.ashx?type=Lead&leadID=" + Convert.ToInt32(hfLeadID.Value) + "&date=" +
txtMachTickDate.Text + "&time=" + txtMachTickTime.Text + "&user=" +
Request.Cookies["upProspektor"]["userName"] + "&model=" +
ddlModel.SelectedItem.Text);
}
else if (!cbMachIcal.Checked && cbMachGcal.Checked)
CreateGcalEvent();
else if (cbMachIcal.Checked && cbMachGcal.Checked)
{
CreateGcalEvent();
Response.Redirect("iCal.ashx?type=Lead&leadID=" + Convert.ToInt32(hfLeadID.Value) + "&date=" +
txtLeadTickDate.Text + "&time=" + txtLeadTickTime.Text + "&user=" +
Request.Cookies["upProspektor"]["userName"] + "&model=" +
ddlModel.SelectedItem.Text);
}
ClearControls(upMachDetails);
UpdateHasMach();
btnUpComm.Style.Add("display", "none");
btnNewMach.Style.Add("display", "none");
btnUpMach.Style.Add("display", "none");
if (hfAddMach.Value.ToString() == string.Empty)
{
hfAddMach.Value = "1";
dvPl = dvProLeads(cmdProLeads());
gvProLeads.DataSource = dvPl;
gvProLeads.DataBind();
this.upReports.Update();
}
Utilities.DisplayAlert(this, this.GetType(), "Machine Info Entered Successfully!");
}
【问题讨论】:
-
感谢您的快速回复,并对重复的帖子感到抱歉。我不是全职开发人员,所以重构是新事物,我听说过这个术语并看到工具栏上的菜单项,但仅此而已。关于如何开始的任何指示?
-
重构代码基本上意味着重新思考/重写它。如果你有很多重复的代码,或者需要在逻辑上重构一些东西,你重写代码来尝试解决这些问题。
-
基本上,您希望获取 ashx 中的代码并将核心功能移动到一个通用组件中,很可能是库项目中的一个类。然后直接从后面的代码调用该类,而不是尝试通过 http 调用 ASHX。
标签: c# asp.net httphandler