The following code works fine on the localhost but after publishing the functionality does not work neither does and it returns the following error. Any ideas?
"Load bug - System.ArgumentNullException: Value cannot be null. Parameter name: String at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at Main.Page_Load(Object sender, EventArgs e) in C:\Users\xyz\source\repos\zyc\bgfn\Main.aspx.cs:line 38"
if (!IsPostBack)
{
try
{
if (ConfigurationManager.AppSettings.Keys.Count < 3)
{
ConfigurationManager.AppSettings["saved"] = DateTime.Now.ToShortTimeString();
ConfigurationManager.AppSettings["houseLeft"] = "60";
ConfigurationManager.AppSettings["carLeft"] = "30";
}
// PROBLEM IS THAT REPUBLISHING WILL RESET THE CONFIG AND HENCE ALL THE OFFERS - MOVE COUNTS TO DB
int houseLeft = int.Parse(ConfigurationManager.AppSettings["houseLeft"]);
int carLeft = int.Parse(ConfigurationManager.AppSettings["carLeft"]);
ConfigurationManager.AppSettings["houseLeft"] = houseLeft.ToString();
ConfigurationManager.AppSettings["carLeft"] = carLeft.ToString();
redeemOne.Text = houseLeft + " left";
redeemTwo.Text = carLeft + " left";
}
catch (Exception exc)
{
lblDebug.Text = "Load bug - " + exc.ToString();
redeemOne.Text = "0" + " left";
redeemTwo.Text = "0" + " left";
}
}