We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Saving HTML with link tags results in tag content being modified


I am opening an HTML file to make some programmatic changes to it, using Aspose.HTML.

I add a link tag to the HTML document like:
var link = htmlDocument.CreateElement(“link”);
link.SetAttribute(“rel”, “stylesheet”);
link.SetAttribute(“href”, “1.0.0/css/my-icons.min.css”);

But when I save the HTML like this:
var options = new HTMLSaveOptions();
options.ResourceHandlingOptions.MaxHandlingDepth = 0;
options.ResourceHandlingOptions.PageUrlRestriction = UrlRestriction.RootAndSubFolders;
options.ResourceHandlingOptions.Default = ResourceHandling.Ignore;

        htmlDocument.Save(indexHtmlPath, options);

The resulting HTML file contains this:
<link rel="stylesheet" href="file:///D:/Projects/MyGenerator/MyGenerator.Win/bin/Debug/net5.0-windows10.0.17763.0/1.0.0/css/my-icons.min.css">

But what I expect (or need) is this:
<link rel="stylesheet" href="1.0.0/css/my-icons.min.css">

I don’t need the component to output related/linked files. I will be putting this generated file into a location where everything will be properly interconnected.

How can I can get the required behaviour?


To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input HTML document.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.