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

Free Support Forum - aspose.com

Authenticating to a proxy


I'm having a problem with images when exporting HTML to Word. Images are stored in a Sharepoint library but due to credentials, the images don't appear in the document.

I've seen this was a known bug in the past and has already been fixed in newer releases:

WORDSNET-927 Add the possibility of authenticate to a proxy before opening the Word document.

However I can't find an example on how to authenticate to the proxy properly. Can you provide any code snippet on how to achieve this?


Hi Annie,

Thanks for your inquiry. Sure, you can authenticate to a proxy to download images by using the following code snippet:

ImageLoadingWithCredentialsHandler imageLoadingWithCredentialsHandler = new ImageLoadingWithCredentialsHandler();

Aspose.Words.LoadOptions loadOption = new Aspose.Words.LoadOptions();

loadOption.ResourceLoadingCallback = imageLoadingWithCredentialsHandler;

Document doc = new Document(@"C:\Temp\in.docx", loadOption);

public class ImageLoadingWithCredentialsHandler : IResourceLoadingCallback


public ImageLoadingWithCredentialsHandler()


mWebClient = new WebClient();


public ResourceLoadingAction ResourceLoading(ResourceLoadingArgs args)


if (args.ResourceType == ResourceType.Image)


Uri uri = new Uri(args.Uri);

if (uri.Host == "www.aspose.com")

mWebClient.Credentials = new NetworkCredential("User1", "akjdlsfkjs");


mWebClient.Credentials = new NetworkCredential("SomeOtherUserID", "wiurlnlvs");

// Download the bytes from the location referenced by the URI.

byte[] imageBytes = mWebClient.DownloadData(args.Uri);


return ResourceLoadingAction.UserProvided;




return ResourceLoadingAction.Default;



private WebClient mWebClient;


I hope, this helps.

Best regards,