网页Licensing与桌面的Licensing应用一致,网页程式在Page_Load事件中检查Licensing。代码如下:
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using Infralution.Licensing;
- public partial class Default : System.Web.UI.Page
- {
- const string LICENSE_PARAMETERS =
- @"<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>";
- const string LICENSE_FILE = "Licensed.lic";
- protected void Page_Load(object sender, EventArgs e)
- {
- EncryptedLicenseProvider provider = new EncryptedLicenseProvider();
- EncryptedLicense license = provider.GetLicense(LICENSE_PARAMETERS, LICENSE_FILE);
- if (license == null)
- {
- LicenseInstallForm licenseForm = new LicenseInstallForm();
- license = licenseForm.ShowDialog("WebApp", "www.geoffhong.com", LICENSE_FILE);
- }
- if (license == null)
- {
- licenseLabel.ForeColor = System.Drawing.Color.Red;
- licenseLabel.Text = "网页程式没有授权.";
- }
- else
- {
- licenseLabel.ForeColor = System.Drawing.Color.Green;
- licenseLabel.Text = "网页程式授权.";
- }
- }
- }