Closed tiagonmas closed 1 year ago
Referral is set in referral page, as a cookie and then redirected to Donation page.
/// <summary>
/// Add cookie and redirect to donations.
/// </summary>
/// <param name="text">The referal code.</param>
/// <returns>Redirect to the donations page.</returns>
public ActionResult OnGet(string text)
{
if (!string.IsNullOrEmpty(text))
{
this.Response.Cookies.Append(
"Referral",
text,
new CookieOptions()
{
HttpOnly = true,
IsEssential = true,
Expires = DateTimeOffset.Now.AddMonths(1),
});
return this.RedirectToPage("./Donation", new { referral = text });
}
else
{
return this.RedirectToPage("./Donation");
}
Apparently having the referral in the query string is not enough. So if you use a link like https://www.alimentestaideia.pt/Donation?referral=EDPDEZ22& and not pass on the referral page (and set the cookie) the referral is not set.
as a workaround for this, try and set the referral from the query string too
apparently donation.cshtml.cs it's already looking into the query string for referral ...
private (string, AlimentaEstaIdeia.Model.Referral) GetReferral()
{
StringValues queryValue;
string result = null;
if (this.Request.Query.TryGetValue("Referral", out queryValue))
{
result = queryValue.ToString();
}
else
{
if (this.Request.Cookies.TryGetValue("Referral", out result))
{
}
}
AlimentaEstaIdeia.Model.Referral referral = null;
if (!string.IsNullOrWhiteSpace(result))
{
referral = this.context.ReferralRepository.GetActiveCampaignsByCode(result);
}
return (result, referral);
}
we are looking at the referral in the POST and not the Get. When we look at the query string in the POST, the Query string is empty, so the referral is not being picked up.
Describe the bug Same people have reported that using the referral code, the overview page is not updated.
To Reproduce Steps to reproduce the behavior:
Expected behavior The campaign overview page should update reflecting the new donation