C# Infralution Licensing System学习笔记(二)网页程式Licensing应用

 网页Licensing与桌面的Licensing应用一致,网页程式在Page_Load事件中检查Licensing。代码如下:

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. using Infralution.Licensing;
  12. public partial class Default : System.Web.UI.Page
  13. {
  14.     const string LICENSE_PARAMETERS =
  15.            @"<LicenseParameters><RSAKeyValue><Modulus>pdTUJtjSDjQPTWPDjWNT+3UgF6fLTZzdFiSnfETIzJKMklsvoJ3Pf5ChJXhOzsV4TrLzobkuiuhStRxJeLD7Wy/7wAJ8TI89yFFCQ12cJicHhDQ3GnItFQvm6sgyR8GIzUrxaKx4uSxROqG3K18WAsmdafcok7QAOrxXoaaidUc=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue><DesignSignature>KxOyXEM2dH7EZiMlzJdhIfD1CcbkJs+6ii/Kge/RdQfXa5KMAsn9QVb7TdXiiuMhu9a1yV2btxd6gZf7+Q/psYa2x7p3arnwb6LLSAwRXPIz0R9lGpZuC4lS3G9/wTBUISwxTkjUBrKoFOPkDr2wPzLSiRr9dOdO5Jbd46tOLJs=</DesignSignature><RuntimeSignature>QrpUIoEadsMT9yZqoHgRxquMydYvu6V0dvu0IdcURklw1uHNKwA/1J0zJr5OZpKqqt/n3vdo+4ZC9jAdusj6fOr3pKE4j1leY7x3Foyz4Aeexo4//Rl+NiCGDYl8wRQZUQL+6kxSjA7lAy3gMLpoOFYb9fxY8YGWA8FAtt1Ta2o=</RuntimeSignature><KeyStrength>7</KeyStrength></LicenseParameters>";
  16.     const string LICENSE_FILE = "Licensed.lic";
  17.     protected void Page_Load(object sender, EventArgs e)
  18.     {
  19.         EncryptedLicenseProvider provider = new EncryptedLicenseProvider();
  20.         EncryptedLicense license = provider.GetLicense(LICENSE_PARAMETERS, LICENSE_FILE);
  21.         if (license == null)
  22.         {
  23.             LicenseInstallForm licenseForm = new LicenseInstallForm();
  24.             license = licenseForm.ShowDialog("WebApp""www.geoffhong.com", LICENSE_FILE);
  25.         }
  26.         if (license == null)
  27.         {
  28.             licenseLabel.ForeColor = System.Drawing.Color.Red;
  29.             licenseLabel.Text = "网页程式没有授权.";
  30.         }
  31.         else
  32.         {
  33.             licenseLabel.ForeColor = System.Drawing.Color.Green;
  34.             licenseLabel.Text = "网页程式授权.";
  35.         }
  36.     }
  37. }

你可能感兴趣的:(C# Infralution Licensing System学习笔记(二)网页程式Licensing应用)