Using System.Uri to remove redundant slash

后端 未结 1 740
日久生厌
日久生厌 2020-12-19 00:24

I have a condition in my program where I have to combine a server (e.g. http://server1.my.corp/) that may or may not have an ending slash with a relative path (

相关标签:
1条回答
  • 2020-12-19 00:59

    Take a look at the constructors for the Uri class. You need to specify a base Uri and a relative path to get the canonized behavior. Try something like this:

    var server = new Uri("http://server1.my.corp/");
    var resource = new Uri(server, "/Apps/TestOne/");
    
    0 讨论(0)
提交回复
热议问题