Issue with Aspose Expression for URL Validation

Hello Team,

We are currently creating following Aspose expression in c#:

string tagText = "<<if [AccountWebsite != null && AccountWebsite != \"\" && !string.IsNullOrWhiteSpace(AccountWebsite) && Uri.IsWellFormedUriString(AccountWebsite, \"Absolute\")]>><<link [AccountWebsite]>><</if>>";

However, this expression is not working as expected. Specifically, the issue appears to be with the Uri.IsWellFormedUriString(AccountWebsite, "Absolute") part of the expression.

It seems this method might not be supported in Aspose expressions. Our goal is to validate the URL

I’ve attached a sample console project that demonstrates the issue for your reference.
Could you please confirm whether Uri.IsWellFormedUriString is supported in Aspose templates, or suggest an alternative approach?

Aspose.7z (858 Bytes)

@pthube To make it work you should modify the template like this:

<<if [AccountWebsite != null && AccountWebsite != "" && !string.IsNullOrWhiteSpace(AccountWebsite) && Uri.IsWellFormedUriString(AccountWebsite, UriKind.Absolute)]>><<link [AccountWebsite]>><</if>>

i.e. instead of string "Absolute" you shoudl use enum value UriKind.Absolute. In addition, you should register Uri and UriKind as known types:

static void MergeTemplate(string templatePath, string outputPath, DataSourceModel data)
{
    var doc = new Document(templatePath);
    var engine = new ReportingEngine();
    engine.KnownTypes.Add(typeof(System.Uri));
    engine.KnownTypes.Add(typeof(System.UriKind));
    engine.BuildReport(doc, data);
    doc.Save(outputPath);
}

Please see our documentation for more information:
https://docs.aspose.com/words/net/setting-up-known-external-types/