Hello,
I am using Aspose.HTML (v. 23.8.1) for .NET.
When I use my app behind a proxy that is not controlled by me, the request for external resources like <link rel="stylesheet" type="text/css" href="https://cdn.sstatic.net/Sites/stackoverflow/primary.css?v=d51441aaae20">
trigger a really long file import.
Is it possible to block all imports of external resources?
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): HTMLNET-4865
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
You can use the Message handler mechanism to intercept network requests, check the protocol in the URI and reject it.
using Aspose.Html;
using Aspose.Html.Net;
using Aspose.Html.Services;
namespace TestMessageHandlers;
internal class Program
{
private static void Main(string[] args)
{
// Create an instance of the Configuration class
using var configuration = new Configuration();
// Call the INetworkService which contains the functionality for managing network operations
var network = configuration.GetService<INetworkService>();
// Add the TimeoutMessageHandler to the top of existing message handler chain
network.MessageHandlers.Insert(0, new NetworkDisabledMessageHandler());
// Prepare path to a source document file
var documentPath = Path.Combine("c:\\temp", "document.html");
// Create an HTML document with a custom configuration
using var document = new HTMLDocument(documentPath, configuration);
}
// Define the NetworkDisabledMessageHandler class that is derived from the MessageHandler class
public class NetworkDisabledMessageHandler : MessageHandler
{
// Override the Invoke() method
public override void Invoke(INetworkOperationContext context)
{
if (context.Request.RequestUri.Protocol == "file:" || context.Request.RequestUri.Protocol == "base64:")
Next(context);
}
}
}
The issues you have found earlier (filed as HTMLNET-4865) have been fixed in this update. This message was posted using Bugs notification tool by avpavlysh