Some Test:
This is Ture:
[Fact]
public void UriEqualTest()
{
//Act
var uri1 = new Uri("https://www.baidu.com");
var uri2 = new Uri("https://www.baidu.com/");
var boolResult = uri2.Equals(uri1);
//Assert
Assert.Equal(uri1, uri2);
Assert.True(boolResult);//True
}
This is Ture:
[Fact]
public void UriUpperEqualTest()
{
//Act
var uri1 = new Uri("https://wWw.bAidu.com");
var uri2 = new Uri("https://www.baidu.com/");
var boolResult = uri2.Equals(uri1);
var operatorResult = (uri1 == uri2);
//Assert
Assert.Equal(uri1, uri2);
Assert.True(boolResult);//True
}
This is False:
[Fact]
public void UrlEqualTest()
{
//Act
var uri1 = new Uri("https://www.baidu.com/aaaa/bbbb");
var uri2 = new Uri("https://www.baidu.com/aaaa/bbbb/");
var boolResult = uri2.Equals(uri1);
//Assert
Assert.Equal(uri1, uri2);
Assert.True(boolResult);//False
}
This is False:
[Fact]
public void UrlUpperEqualTest()
{
//Act
var uri1 = new Uri("https://www.baidu.com/AAaa/bbbb");
var uri2 = new Uri("https://www.baidu.com/aAAa/bbbb");
var boolResult = uri2.Equals(uri1);
var operatorResult = (uri1 == uri2);
//Assert
Assert.Equal(uri1, uri2);
Assert.True(boolResult);//False
}
This is True:
[Fact]
public void UriUpperEqualAndPathTest()
{
//Act
var uri1 = new Uri("https://www.baiDu.com/aaaa/bbbb");
var uri2 = new Uri("https://www.Baidu.com/aaaa/bbbb");
var boolResult = uri2.Equals(uri1);
//Assert
Assert.Equal(uri1, uri2);
Assert.True(boolResult);//True
}
So,The Host not case sensitive? but path case sensitive??
And I want all Uri dot not case sensitive and dot not case '/',What should I do?
And I want all Uri dot not case sensitive and dot not case '/',What should I do?
And I want all Uri dot not case sensitive and dot not case '/',What should I do?
And in aspnet core mvc, if i use route
[HttpGet("/private/head")] and [HttpGet("/private/HeAd")] and [HttpGet("/private/head/")]
It's error! the error is:
AmbiguousActionException: Multiple actions matched. The following actions matched route data and had all constraints satisfied:
https://stackoverflow.com/a/2581418/34092 states:
So, looking at your examples:
They are the same, since
always sends a request ending with a slash
. They are thus equivalent.https://serverfault.com/a/261344 states:
Thus, the two are equivalent (since they differ only by case and the slash immediately after the host).
OK, this seems like the first scenario, but it isn't. The first scenario treats them as equivalent since it is 'pure domain name' (i.e. straight after the host). This is different (i.e. the slash is at the end, not straight after the host), and thus they aren't equivalent (on all web servers). Thus not equal.
The path and querystring are case sensitive. Thus these are not equal. Some web servers / programming environments (e.g. ASP.NET MVC) may act case-insensitive, but according to the spec the path and querystring are case sensitive (since some web servers are case sensitive).
The only difference is the case of the host. Thus they are equal.
This is because ASP.NET MVC is generally not case sensitive. Force case-sensitive routing in ASP.NET MVC may be useful for this part of your problem.