How to check if two different URLs point to the same resource?

Suppose I have a website hosted on a computer with the name "linux" and it is part of two different networks with the addresses 192.168.1.1 and 10.1.1.1. When working locally on linux, I can access this website at the following URLs:

http://192.168.1.1/  http://10.1.1.1/  http: // linux /  http: // localhost /  http://127.0.0.1/

Working on another computer on the network "10.1.1.0/24" I can use the following:

http://10.1.1.1/  http: // linux /

But on "192.168.1.0/24" I can only use:

http://192.168.1.1/  http: // linux /

I am developing an application that compares URLs, and in this application context, two URLs are equal if they point to the same resource.

Is there a quick way to make such a comparison using the URI class in C #?

+3
source share
2 answers

The URI class cannot help you; it can only determine if two URIs are the same URIs, and they are only the same URI if they have the same server name / IP address.

The best option is to load a resource from both URLs and see if it is the same resource, checking for equality and assuming that two resources are the same resource if they are the same sequence of bits.

, . -, " " URI, , , ... - Thiado de Arruda

, , , , , , .

- . URI.Host URI, , . .

+3

, python ( , ), , -.

0

Source: https://habr.com/ru/post/1752323/


All Articles