You can compute and pass a hash of your parameters along with your querystring. On your landing page, compute the hash again and compare it with the query string hash, if both are not same it means the URL is tampered.
You can make functions inside a utility class like
const string secretKey = "%%YoUrSeCrEtKeY##";
public static string CreateTamperProofUrl(string pageUrl)
{
try
{
return HttpUtility.UrlEncode(CreateDigest(pageUrl.Trim()));
}
catch (Exception)
{
throw;
}
}
private static string CreateDigest(string pageUrl)
{
string urlToEncode = secretKey + pageUrl + secretKey;
var hasher = new MD5CryptoServiceProvider();
var encoder = new UTF8Encoding();
byte[] hashedDataBytes = hasher.ComputeHash(encoder.GetBytes(urlToEncode));
string signatureData = Convert.ToBase64String(hashedDataBytes);
return signatureData;
}
public static bool IsValidDigest(string pageUrl, string receivedDigest)
{
if (receivedDigest == null)
{
return false;
}
string expectedDigest = CreateDigest(pageUrl);
if (string.Compare(receivedDigest, expectedDigest) != 0)
{
return false;
}
else
return true;
}
On your landing page just check like this
if (!Page.IsPostBack)
{
if (Request.QueryString["Digest"] != null)
{
// compare the digest
string id = Request.QueryString["fid"];
string digest = Request.QueryString["Digest"];
if (Utility.IsValidDigest(id, digest))
{
lblStatus.ForeColor = System.Drawing.Color.DarkGreen;
lblStatus.Text = "Valid digest received";
}
else
{
lblStatus.ForeColor = System.Drawing.Color.Red;
lblStatus.Text = "Url is tampered!";
}
}
}