简体   繁体   中英

Different behavior System.Uri

I'm newbie to .Net especially 4.5 version.

I have written library which use class System.Uri object. when I invoke code:

Uri uri = new Uri("http://myUrl/%2F");

in console application it create new Uri object with AbsoluteUri set to

"http://myurl/%2F", 

but when I invoke the same code in web service application AbsoluteUri is set to

"http://myurl//"

How can I use "%2f" without conversion in server aplication

%2f convert to /

try with

http://myurl/%252F

%25 is equal to % then %252F will convert to %2F at server side, as you expected

Uri uri = new Uri("http://myUrl/%252F");
uri.LocalPath //  "/%2F"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM