而使用URI类保持URL连接codeD [英] Keep url encoded while using URI class

查看:160
本文介绍了而使用URI类保持URL连接codeD的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从LinkedIn获取公开的个人资料信息。要做到这一点我必须提供
<一href="http://api.linkedin.com/v1/people/url=public-profile-url">http://api.linkedin.com/v1/people/url=public-profile-url,其中,公众瞩目,URL必须是URL连接codeD。

I'm trying to get public profile information from LinkedIn. To achieve this I have to provide
http://api.linkedin.com/v1/people/url=public-profile-url, where public-profile-url MUST be URL encoded.

问题是,.NET类,如HttpClient的,WebRequest的使用等,这似乎册封所提供的网址,让我不能得到正确格式的请求发送Uri类。

The issue is that .NET classes such as HttpClient, WebRequest etc use Uri class which seems to "canonize" the provided URL, so that I can't get the proper formatted request sent.

URI必须是:

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

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

不过是:

<一个href="http://api.linkedin.com/v1/people/url=http://www.linkedin.com/in/iftachragoler">http://api.linkedin.com/v1/people/url=http://www.linkedin.com/in/iftachragoler

就这样,我从LinkedIn获得错误的请求。

In this way, I get 'Bad Request' from LinkedIn.

有什么办法,我可以有乌里/ UriBuilder不脱$ C C的URL $?

Is there any way I can have Uri/UriBuilder not to decode that URL?

谢谢!

推荐答案

有一个关于该报告对微软连接。默认情况下逃脱斜线不是由于安全原因不允许的。

There is report about that on Microsoft connect. By default escaped slashes not allowed due to security reasons.

<一个href="http://connect.microsoft.com/VisualStudio/feedback/details/94109/">http://connect.microsoft.com/VisualStudio/feedback/details/94109/

CITES从那里:

我尝试使用LinkedIn的API,为此我需要以下链接:   <一href="http://api.linkedin.com/v1/people/url=http%3A%2F%2Fwww.linkedin.com%2Fin%2Fyourlinkedinname:public">http://api.linkedin.com/v1/people/url=http%3A%2F%2Fwww.linkedin.com%2Fin%2Fyourlinkedinname:public

I try to use the LinkedIn api, for which I need the following link: http://api.linkedin.com/v1/people/url=http%3A%2F%2Fwww.linkedin.com%2Fin%2Fyourlinkedinname:public

正如你所看到的URL字段需要转义。如何解决此问题?

As you can see the url field needs to be escaped. How to solve this?

答:

我们目前不允许逃脱斜线和点出现在   路径,因为这是当向攻击者的服务器URI中的常用方法   方案支持路径COM pression。

We currently don't allow escaped slashes and dots to appear in the path because this is a common way to attacker a server when the URI scheme supports path compression.

但是,标签与解决方法。其中一人对.NET 4是添加的app.config:

But there is tab with workarounds. One of them for .NET 4 is to add app.config:

有关.NET 4.0,可以通过配置文件控制的:

For .NET 4.0, you can control this through the config file:

<一个href="http://msdn.microsoft.com/en-us/library/bb882619.aspx">http://msdn.microsoft.com/en-us/library/bb882619.aspx

<一个href="http://msdn.microsoft.com/en-us/library/ee656539.aspx">http://msdn.microsoft.com/en-us/library/ee656539.aspx

<configuration>
<uri>
    <schemeSettings>
     <clear/>
     <add name="http" genericUriParserOptions="DontUnescapePathDotsAndSlashes"/>
    </schemeSettings>
</uri>
</configuration>

有关.NETs之前,.NET对于Uri类构造函数参数dontEscape。对于.NET 4这是过时的。

For .NETs before .NET was constructor for Uri class with parameter "dontEscape". For .NET 4 it's obsolete.

这篇关于而使用URI类保持URL连接codeD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆