我有一个webform页面,当用户点击表单加载事件触发时,在表单加载事件上我采用会话数据更新db然后我返回带有return关键字的webform。令我惊讶的是负载事件再次开火。
我给Response.end()
;它不起作用。
在webform我只有asp.net标签和文本框控件只有一个按钮控件。
任何解决方案或想法?
protected void Page_Load(object sender, EventArgs e)
{
//check postback
if (!IsPostBack)
{
String username = String.Empty;
double amount = 0.0;
try
{
//check user session
if ((Session["username"] != null) && (Session["amount"] != null))
{
username = Convert.ToString(Session["username"]);
amount = Convert.ToDouble(Session["amount"]);
//assign session user name
lblUserName.Text = username;
lblTranAmount.Text = Convert.ToString(amount);
}
}
catch (Exception e1)
{
txtError.Visible = true;
txtError.Text = "your payment successfull " +" \n" +"We could not update the papercut due to User session Not Available: " + e1.Message + " " + e1.Source;
System.Diagnostics.Debug.WriteLine(e1.Message + "\n" + e1.Source);
return;
}
//check user balance
ServerCommandProxy serverProxy = null;
double tempCurrentBalance = 0.0;
try
{
serverProxy = new ServerCommandProxy("217.206.49.71", 9191, "netm0an");//server 217.206.49.71
tempCurrentBalance = serverProxy.GetUserAccountBalance(username, "");
lblCurrentBalance.Text = Convert.ToString(tempCurrentBalance);
//
}
catch (Exception e2)
{
lblCurrentBalance.Text = "Due to Erro not able update";
txtError.Visible = true;
txtError.Text = "your payment successfull " + " \n " + "We could not update the papercut balance amount Due to the below Exception : " + "\n " + "XML Web service API access violations: due to Server IP Address: 217.206.49.71 " + "\n " + e2.Message + " \n " + e2.Source;
System.Diagnostics.Debug.WriteLine(e2.Message + "\n" + e2.Source);
return;
}
//update papercut balance by xml rpc api
try
{
//listuseraccounts
// String [] accounts = serverProxy.ListUserAccounts(0, 1000);
serverProxy.AdjustUserAccountBalance(username, amount, "Ogone Payment updated Balance: $" + (tempCurrentBalance + amount), "Default");
double totalBalance = (tempCurrentBalance + amount);
lblTotalBalance.Text = Convert.ToString(totalBalance);
serverProxy = null;
Session["username"] = null;
Session["amount"] = null;
username = string.Empty;
amount = 0.0;
return;// after this line form loading again why?
}
catch (Exception e3)
{
lblTotalBalance.Text = "Due to Error not able update";
txtError.Visible = true;
txtError.Text = "your payment successfull " +" \n " + "We could not update the papercut balance amount Due to the below Exception : " + "\n " + "XML Web service API access violations: due to Server IP Address: 217.206.49.71 " + "\n " + e3.Message + " \n " + e3.Source;
System.Diagnostics.Debug.WriteLine(e3.Message + "\n" + e3.Source);
return;
}
}
}