title: Decrypt WebResource.axd URL generated on HTTPS instance
body: <p>I have below mentioned code:</p>
  
  <pre><code>string urlEncodedData = URL.Text;
  
  byte[] encryptedData = HttpServerUtility.UrlTokenDecode(urlEncodedData);
  
  Type machineKeySection = typeof(System.Web.Configuration.MachineKeySection);
  Type[] paramTypes = new Type[] { typeof(bool), typeof(byte[]), typeof(byte[]), typeof(int), typeof(int) };
  MethodInfo encryptOrDecryptData = machineKeySection.GetMethod("EncryptOrDecryptData", BindingFlags.Static | BindingFlags.NonPublic, null, paramTypes, null);
  
  try
  {
       byte[] decryptedData = (byte[])encryptOrDecryptData.Invoke(null, new object[] { false, encryptedData, null, 0, encryptedData.Length });
       string decrypted = Encoding.UTF8.GetString(decryptedData);
  
       decryptedLabel.BackColor = Color.Lime;
       decryptedLabel.Text = decrypted;
  }
  catch (TargetInvocationException)
  {
       decryptedLabel.BackColor = Color.Red;
       decryptedLabel.Text = "Error decrypting data. Are you running your page on the same server and inside the same application as the web resource URL that was generated?";
  }
  </code></pre>
  
  <p>It Decrypts and tell me details about webresource.
  locally it works fine.
  <img src="https://i.stack.imgur.com/Bn1qZ.png" alt="enter image description here"> </p>
  
  <p>But on production it always gives me below message from catch block</p>
  
  <p><strong>Error decrypting data. Are you running your page on the same server and inside the same application as the web resource URL that was generated?</strong></p>
  
  <p>The only difference I have is production being on HTTPS. Is above code valid for HTTPS also, or do I have to make change(s) to it?</p>