PDA

View Full Version : سوال: خطا - Value cannot be null. Parameter name: String



razeghaik1
پنج شنبه 19 مهر 1397, 07:27 صبح
ا سلام و احترام
دوستان من با استفاده از یک سمپل توی اینترنت اتصال درگاه بانک ملت رو توی سایتم استفاده کردم.همه چی خوب کار می کنه و پول از حساب کسر می شه و زمانی که ریدایرکت می شه به صفحه ای که باید بگه همه چیز صحیح انجام شده با خطای زیر مواجه می شم و بعد از چند ثانیه مجدد پول کسر شده از حساب مشتری به علت عدم تراکنش صحیح به حساب مشتری واریز می شه.
از دوستان کسی می تونه کمکم کنه؟ ممنون

Server Error in '/' Application.

Value cannot be null.
Parameter name: String
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: String
اگر اطلاعات خاصی هم میتونه به حل مساله کمک کنه تا ارسال کنم.ممنون

اینم کدهای صفحه صلی

اینم کدهای صفحه صلی
namespace BankMellat_WebForms
{
public partial class _default : System.Web.UI.Page
{
public static readonly string PgwSite = ConfigurationManager.AppSettings["PgwSite"];
public static readonly string CallBackUrl = ConfigurationManager.AppSettings["CallBackUrl"];
public static readonly string TerminalId = ConfigurationManager.AppSettings["TerminalId"];
public static readonly string UserName = ConfigurationManager.AppSettings["UserName"];
public static readonly string UserPassword = ConfigurationManager.AppSettings["UserPassword"];
void BypassCertificateError()
{
ServicePointManager.ServerCertificateValidationCal lback +=
delegate(
Object sender1,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
return true;
};
}
public static string RefId = "";
public string SetDefaultDate()
{
return DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Day.ToString().PadLeft(2, '0');

}
public string SetDefaultTime()
{
return DateTime.Now.Hour.ToString().PadLeft(2, '0') + DateTime.Now.Minute.ToString().PadLeft(2, '0') + DateTime.Now.Second.ToString().PadLeft(2, '0');
}
protected void Page_Load(object sender, EventArgs e)
{

}

protected void btnpayment_Click(object sender, EventArgs e)
{
//get values from form
string _name = txtname.Text;
string _email = txtemail.Text;
string __amount = txtamount.Text;
int _amount = int.Parse(__amount);
//save record to database
int? record_id = 0;
var db = new dbDataContext();
db.InsertPayment(_name, _email, _amount, "پرداخت نشده", ref record_id);
//================================================== ========================
try
{
string result = "";
BypassCertificateError();
BankMellat.PaymentGatewayClient bp = new BankMellat.PaymentGatewayClient();
result = bp.bpPayRequest(Int64.Parse(TerminalId), UserName, UserPassword, long.Parse(record_id.Value.ToString()), _amount, SetDefaultDate(), SetDefaultTime(), "irarzan.ir", CallBackUrl, 0);
string[] res = result.Split(',');
if (res[0] == "0")
{
db.UpdatePayment("پرداخت نشده", res[1], "", record_id);
ClientScript.RegisterStartupScript(typeof(Page), "clientscript", "<script>postRefId('" + res[1] + "')</script>");
}
else
{
msglabel.Text = "خطای " + res[0] + " در ارتباط با بانک";
}
}
catch
{
msglabel.Text = "خطا در ارتباط با بانک";
}
//================================================== ========================

}
}
}



namespace BankMellat_WebForms
{
public partial class payment : System.Web.UI.Page
{
public static readonly string PgwSite = ConfigurationManager.AppSettings["PgwSite"];
public static readonly string CallBackUrl = ConfigurationManager.AppSettings["CallBackUrl"];
public static readonly string TerminalId = ConfigurationManager.AppSettings["TerminalId"];
public static readonly string UserName = ConfigurationManager.AppSettings["UserName"];
public static readonly string UserPassword = ConfigurationManager.AppSettings["UserPassword"];
void BypassCertificateError()
{
ServicePointManager.ServerCertificateValidationCal lback +=
delegate(
Object sender1,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
return true;
};
}
public static string RefId = "";
public string SetDefaultDate()
{
return DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Day.ToString().PadLeft(2, '0');

}
public string SetDefaultTime()
{
return DateTime.Now.Hour.ToString().PadLeft(2, '0') + DateTime.Now.Minute.ToString().PadLeft(2, '0') + DateTime.Now.Second.ToString().PadLeft(2, '0');
}
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Params["ResCode"] != null)
{
string _rescode = Request.Params["ResCode"];
string _refid = Request.Params["RefId"];
string _saleorderid = Request.Params["SaleOrderId"];
string _salerefrenceid = Request.Params["SaleRefrenceId"];
if (_rescode == "0")
{
string result = "";
BypassCertificateError();
BankMellat.PaymentGatewayClient bp = new BankMellat.PaymentGatewayClient();
result = bp.bpVerifyRequest(Int64.Parse(TerminalId), UserName, UserPassword, long.Parse(_saleorderid), long.Parse(_saleorderid), long.Parse(_salerefrenceid));
if (result == "0")
{
var db = new dbDataContext();
var payment_id = db.tblPayments.Where(c => c.RefID == _refid).Single();
db.UpdatePayment("پرداخت شده", _refid, _salerefrenceid, payment_id.id);
msglabel.Text = "پرداخت شما با موفقیت انجام شد" + "<br />" + "شماره پیگیری تراکنش: " + _salerefrenceid;
}
else
{
msglabel.Text = "پرداخت آنلاین با خطا مواجه شده است.";
}
}
else
{
msglabel.Text = "پرداخت آنلاین با خطا مواجه شده است.";
}
}
}
}
}

----------------------------------------------------------------
این هم Stack Trace خطا

Stack Trace:
[ArgumentNullException: Value cannot be null.
Parameter name: String]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +12727501
System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt) +133
System.Int64.Parse(String s) +24
System.Web.UI.Control.OnLoad(EventArgs e) +95
BankMellat_WebForms.payment.Page_Load(Object sender, EventArgs e) +698
System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender, EventArgs e) +51
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678
System.Web.UI.Control.LoadRecursive() +59

razeghaik1
پنج شنبه 19 مهر 1397, 10:45 صبح
ا سلام و احترام
دوستان من با استفاده از یک سمپل توی اینترنت اتصال درگاه بانک ملت رو توی سایتم استفاده کردم.همه چی خوب کار می کنه و پول از حساب کسر می شه و زمانی که ریدایرکت می شه به صفحه ای که باید بگه همه چیز صحیح انجام شده با خطای زیر مواجه می شم و بعد از چند ثانیه مجدد پول کسر شده از حساب مشتری به علت عدم تراکنش صحیح به حساب مشتری واریز می شه.
از دوستان کسی می تونه کمکم کنه؟ ممنون

Server Error in '/' Application.

Value cannot be null.
Parameter name: String
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: String
اگر اطلاعات خاصی هم میتونه به حل مساله کمک کنه تا ارسال کنم.ممنون

اینم کدهای صفحه صلی

اینم کدهای صفحه صلی
namespace BankMellat_WebForms
{
public partial class _default : System.Web.UI.Page
{
public static readonly string PgwSite = ConfigurationManager.AppSettings["PgwSite"];
public static readonly string CallBackUrl = ConfigurationManager.AppSettings["CallBackUrl"];
public static readonly string TerminalId = ConfigurationManager.AppSettings["TerminalId"];
public static readonly string UserName = ConfigurationManager.AppSettings["UserName"];
public static readonly string UserPassword = ConfigurationManager.AppSettings["UserPassword"];
void BypassCertificateError()
{
ServicePointManager.ServerCertificateValidationCal lback +=
delegate(
Object sender1,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
return true;
};
}
public static string RefId = "";
public string SetDefaultDate()
{
return DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Day.ToString().PadLeft(2, '0');

}
public string SetDefaultTime()
{
return DateTime.Now.Hour.ToString().PadLeft(2, '0') + DateTime.Now.Minute.ToString().PadLeft(2, '0') + DateTime.Now.Second.ToString().PadLeft(2, '0');
}
protected void Page_Load(object sender, EventArgs e)
{

}

protected void btnpayment_Click(object sender, EventArgs e)
{
//get values from form
string _name = txtname.Text;
string _email = txtemail.Text;
string __amount = txtamount.Text;
int _amount = int.Parse(__amount);
//save record to database
int? record_id = 0;
var db = new dbDataContext();
db.InsertPayment(_name, _email, _amount, "پرداخت نشده", ref record_id);
//================================================== ========================
try
{
string result = "";
BypassCertificateError();
BankMellat.PaymentGatewayClient bp = new BankMellat.PaymentGatewayClient();
result = bp.bpPayRequest(Int64.Parse(TerminalId), UserName, UserPassword, long.Parse(record_id.Value.ToString()), _amount, SetDefaultDate(), SetDefaultTime(), "irarzan.ir", CallBackUrl, 0);
string[] res = result.Split(',');
if (res[0] == "0")
{
db.UpdatePayment("پرداخت نشده", res[1], "", record_id);
ClientScript.RegisterStartupScript(typeof(Page), "clientscript", "<script>postRefId('" + res[1] + "')</script>");
}
else
{
msglabel.Text = "خطای " + res[0] + " در ارتباط با بانک";
}
}
catch
{
msglabel.Text = "خطا در ارتباط با بانک";
}
//================================================== ========================

}
}
}



namespace BankMellat_WebForms
{
public partial class payment : System.Web.UI.Page
{
public static readonly string PgwSite = ConfigurationManager.AppSettings["PgwSite"];
public static readonly string CallBackUrl = ConfigurationManager.AppSettings["CallBackUrl"];
public static readonly string TerminalId = ConfigurationManager.AppSettings["TerminalId"];
public static readonly string UserName = ConfigurationManager.AppSettings["UserName"];
public static readonly string UserPassword = ConfigurationManager.AppSettings["UserPassword"];
void BypassCertificateError()
{
ServicePointManager.ServerCertificateValidationCal lback +=
delegate(
Object sender1,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
{
return true;
};
}
public static string RefId = "";
public string SetDefaultDate()
{
return DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Day.ToString().PadLeft(2, '0');

}
public string SetDefaultTime()
{
return DateTime.Now.Hour.ToString().PadLeft(2, '0') + DateTime.Now.Minute.ToString().PadLeft(2, '0') + DateTime.Now.Second.ToString().PadLeft(2, '0');
}
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Params["ResCode"] != null)
{
string _rescode = Request.Params["ResCode"];
string _refid = Request.Params["RefId"];
string _saleorderid = Request.Params["SaleOrderId"];
string _salerefrenceid = Request.Params["SaleRefrenceId"];
if (_rescode == "0")
{
string result = "";
BypassCertificateError();
BankMellat.PaymentGatewayClient bp = new BankMellat.PaymentGatewayClient();
result = bp.bpVerifyRequest(Int64.Parse(TerminalId), UserName, UserPassword, long.Parse(_saleorderid), long.Parse(_saleorderid), long.Parse(_salerefrenceid));
if (result == "0")
{
var db = new dbDataContext();
var payment_id = db.tblPayments.Where(c => c.RefID == _refid).Single();
db.UpdatePayment("پرداخت شده", _refid, _salerefrenceid, payment_id.id);
msglabel.Text = "پرداخت شما با موفقیت انجام شد" + "<br />" + "شماره پیگیری تراکنش: " + _salerefrenceid;
}
else
{
msglabel.Text = "پرداخت آنلاین با خطا مواجه شده است.";
}
}
else
{
msglabel.Text = "پرداخت آنلاین با خطا مواجه شده است.";
}
}
}
}
}

----------------------------------------------------------------
این هم Stack Trace خطا

Stack Trace:
[ArgumentNullException: Value cannot be null.
Parameter name: String]
System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +12727501
System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt) +133
System.Int64.Parse(String s) +24
System.Web.UI.Control.OnLoad(EventArgs e) +95
BankMellat_WebForms.payment.Page_Load(Object sender, EventArgs e) +698
System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender, EventArgs e) +51
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678
System.Web.UI.Control.LoadRecursive() +59

دوستان کسی نظری یا کمکی نداره؟