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

Free Support Forum - aspose.com

Compare Doc file in C# mvc web application

Hi All,

I am using aspose version 22.10 for the document ,the paragraph contain text and hyperlink
text modification working as expected but hyperlink modification its not getting modification URL content

below is my code

comparisonOfEachParagraphModel.docsrc.Save(Path.Combine(comparisonOfEachParagraphModel.comparisonModel.filePath,  Source1.docx));
comparisonOfEachParagraphModel.docres.Save(Path.Combine(comparisonOfEachParagraphModel.comparisonModel.filePath, "version1.docx"));
comparisonOfEachParagraphModel.docsrc.Compare(comparisonOfEachParagraphModel.docres, "Version " + comparisonOfEachParagraphModel.comparisonModel.j, DateTime.Now, comparisonOfEachParagraphModel.comparisonModel.options);
var deletion = comparisonOfEachParagraphModel.docsrc.Revisions.Where(p => p.RevisionType == RevisionType.Deletion).ToArray();

version1.docx (11.4 KB)
Source1.docx (11.3 KB)

@vengatachalamg4 I cannot reproduce the problem on my side using the latest 23.2 version of Aspose.Words. I see both field value and field code in the revisions.
Maybe you accidently set CompareOptions.IgnoreFields and the hyperlink field is not compared.

If i setting CompareOptions.IgnoreFields is false the comparison result coming like , attached referenceerrorimage.PNG (7.0 KB)

@vengatachalamg4 The output is the same as MS Word output: ms.docx (12.3 KB)

So the behavior is expected.

could you share me the code in c# , Configuration

How can i get only web side name from the text like this Medicare website ( HYPERLINK "http://www.medicare.gov" www.medicare.gov) or by calling
any option is there ?

@vengatachalamg4 I have used the default compare options and the following simple code for testing:

Document original = new Document(@"C:\Temp\Source1.docx");
Document changed = new Document(@"C:\Temp\version1.docx");

original.Compare(changed, "test", DateTime.Now);

var deletion = original.Revisions.Where(p => p.RevisionType == RevisionType.Deletion).ToArray();
foreach(Revision revision in deletion) {

You can get the address from the field:

FieldHyperlink link = doc.Range.Fields.Where(f => f.Type == FieldType.FieldHyperlink).Cast<FieldHyperlink>().FirstOrDefault();

Or by parsing the field code string.

when i am set CompareOptions.IgnoreFields =true there are of difference showing for URL modify like below

Differences DifferenceType
HYPERLINK "http://www.medicare.gov" Deletion
www.medicare.gov Deletion
HYPERLINK "http://www.medicareHealth.gov" Insertion
www.medicareHealth.gov Insertion

but actual difference is moify some text on the URL Source1.docx (11.3 KB)
version1.docx (11.4 KB)

Any suggestion ?

@vengatachalamg4 I cannot preproduce the problem on my side. I have used the following code for testing:

Document original = new Document(@"C:\Temp\Source1.docx");
Document changed = new Document(@"C:\Temp\version1.docx");

CompareOptions options = new CompareOptions();
options.IgnoreFields = true;
original.Compare(changed, "test", DateTime.Now, options);

foreach(RevisionGroup group in original.Revisions.Groups) {
    Console.WriteLine("{0} - {1}", group.Text, group.RevisionType);


And here is the output document: out.docx (9.3 KB)

The problem on your side might occur because you missed to pass CompareOptions into the Compare method.

Hi Alexey,
Thanks for your replaying and given your thoughts .

sorry for my inconvenience
if you set ompareOptions.IgnoreFields =true , Hyperlink comparison not happened, on your given output file, our requirement is comparing source document with version document if found any changes on the version file we need to height the changes including hyper link

@vengatachalamg4 Hyperlink is a field. So when you ignore fields upon comparison it is expected that hyperlink fields will not be compared.

Yes Alexey, Exactly.

1 Like