c# - Keep url encoded while using URI class -


i'm trying public profile information linkedin. achieve have provide
http://api.linkedin.com/v1/people/url=public-profile-url, public-profile-url must url encoded.

the issue .net classes such httpclient, webrequest etc use uri class seems "canonize" provided url, can't proper formatted request sent.

the uri must be:

http://api.linkedin.com/v1/people/url=http%3a%2f%2fwww.linkedin.com%2fin%2fiftachragoler

but is:

http://api.linkedin.com/v1/people/url=http://www.linkedin.com/in/iftachragoler

in way, 'bad request' linkedin.

is there way can have uri/uribuilder not decode url?

there report on microsoft connect. default escaped slashes not allowed due security reasons.

http://connect.microsoft.com/visualstudio/feedback/details/94109/

cites there:

i try use linkedin api, need following link: http://api.linkedin.com/v1/people/url=http%3a%2f%2fwww.linkedin.com%2fin%2fyourlinkedinname:public

as can see url field needs escaped. how solve this?

answer:

we don't allow escaped slashes , dots appear in path because common way attacker server when uri scheme supports path compression.

but there tab workarounds. 1 of them .net 4 add app.config:

for .net 4.0, can control through config file:

http://msdn.microsoft.com/en-us/library/bb882619.aspx

http://msdn.microsoft.com/en-us/library/ee656539.aspx

<configuration> <uri>     <schemesettings>      <clear/>      <add name="http" genericuriparseroptions="dontunescapepathdotsandslashes"/>     </schemesettings> </uri> </configuration> 

for .nets before .net constructor uri class parameter "dontescape". .net 4 it's obsolete.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -