在 Web.config 中設定授權金鑰
The problem has been resolved as of IronWebScraper version 2024.3.6.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronWebScraper must be licensed for development.
對於較舊版本的 IronWebScraper,特別是介於版本之間的版本2023.4.13和2024.3.6,已知存在授權問題於:
- ASP.NET 專案
.NET Framework 版本 >= 4.6.2
儲存在
Web.config
檔案中的金鑰不會被產品檢索和使用。
變通方法
要解決此問題,建議在程式碼中使用 ConfigurationManager 從 Web.config
文件中檢索授權密鑰,然後將其應用於 License.LicenseKey 屬性。
範例:
<configuration>
...
<appSettings>
<add key="IronWebScraper.LicenseKey" value="IRONWEBSCRAPER-MYLICENSE-KEY-1EF01"/>
</appSettings>
...
</configuration>
根據上面提供的 XML 文件,我們可以使用 ConfigurationManager 來檢索許可金鑰值,並將其傳遞給 IronWebScraper.License.LicenseKey 屬性。
using System.Configuration;
string licenseKey = ConfigurationManager.AppSettings ["IronWebScraper.LicenseKey"];
IronWebScraper.License.LicenseKey = licenseKey;
using System.Configuration;
string licenseKey = ConfigurationManager.AppSettings ["IronWebScraper.LicenseKey"];
IronWebScraper.License.LicenseKey = licenseKey;
Imports System.Configuration
Private licenseKey As String = ConfigurationManager.AppSettings ("IronWebScraper.LicenseKey")
IronWebScraper.License.LicenseKey = licenseKey