this is only happening while i view my page in the live site.
my complete code :
protected void downloadBtn_Click(object sender, EventArgs e)
{
EventLogProvider.LogException("00000000000", "CMSWebParts_MyWebParts_DownloadButton", new Exception("ex: "));
if (WithCaptcha && captchaElem.Visible)
{
if (captchaElem.IsValid())
{
if (string.IsNullOrEmpty(ItemId))
{
CustomTableItem cti = CustomTableItem.New("customtable.Status");
cti.SetValue("UserIp", HttpContext.Current.Request.UserHostAddress);
cti.SetValue("UserGuid", MembershipContext.AuthenticatedUser.UserGUID);
cti.SetValue("UserName", MembershipContext.AuthenticatedUser.UserName);
cti.SetValue("UserEmailAddress", MembershipContext.AuthenticatedUser.Email);
cti.SetValue("PageAlias", HttpContext.Current.Request.RawUrl.Substring(firstIndex, lastIndex - firstIndex));
cti.SetValue("DownloadCount", 1);
cti.Insert();
}
else
{
var existing = CustomTableItemProvider.GetItem(int.Parse(ItemId), "customtable.Status");
var currentDownloadCount = ValidationHelper.GetInteger(existing.GetValue("DownloadCount", -1), -1);
if (currentDownloadCount <= MaxDownloadCount)
{
existing.SetValue("DownloadCount", currentDownloadCount + 1);
existing.Update();
}
else
{
return;
}
}
var documentFile = CustomTableItemProvider.GetItems("customtable.Document")
.TopN(1)
.WhereEquals("FileNameGuid", EcGuid);
if (!DataHelper.DataSourceIsEmpty(documentFile))
{
DownloadFile(documentFile.Tables[0].Rows[0]["DocFilePath"].ToString(),
documentFile.Tables[0].Rows[0]["FileNameGuid"].ToString() + ".pdf");
}
}
else
{
SecurityCodeMessage.Text = "error100";
}
}
else
{
if (string.IsNullOrEmpty(ItemId))
{
CustomTableItem cti = CustomTableItem.New("customtable.Status");
cti.SetValue("UserIp", HttpContext.Current.Request.UserHostAddress);
cti.SetValue("UserGuid", MembershipContext.AuthenticatedUser.UserGUID);
cti.SetValue("UserName", MembershipContext.AuthenticatedUser.UserName);
cti.SetValue("UserIsRegister", !MembershipContext.AuthenticatedUser.IsPublic());
cti.SetValue("PageAlias", HttpContext.Current.Request.RawUrl.Substring(firstIndex, lastIndex - firstIndex));
cti.SetValue("DownloadCount", 1);
cti.Insert();
}
else
{
var existing = CustomTableItemProvider.GetItem(int.Parse(ItemId), "customtable.Status");
var currentDownloadCount = ValidationHelper.GetInteger(existing.GetValue("DownloadCount", -1), -1);
if (currentDownloadCount <= MaxDownloadCount)
{
existing.SetValue("DownloadCount", currentDownloadCount + 1);
existing.Update();
}
else
{
return;
}
}
var documentFile = CustomTableItemProvider.GetItems("customtable.Document")
.TopN(1)
.WhereEquals("FileNameGuid", EcGuid);
if (!DataHelper.DataSourceIsEmpty(documentFile))
{
DownloadFile(documentFile.Tables[0].Rows[0]["DocFilePath"].ToString(),
documentFile.Tables[0].Rows[0]["FileNameGuid"].ToString() + ".pdf");
}
}
}