简体   繁体   English

HttpWebRequest截断URL中包含非英语符号

[英]HttpWebRequest truncating URL with non-english symbols in it

I'm creating HttpWebRequest with a dynamic URL that can sometimes contain Russian symbols. 我正在创建带有动态URL的HttpWebRequest,该URL有时可能包含俄语符号。 And sometimes I'm encounter an issue I not sure how to deal with: While encoding to URL each of RU characters has been converted into URL character-entity equivalents (%20...). 有时我遇到一个我不确定如何处理的问题:在对URL进行编码时,每个RU字符都已转换为等效的URL字符实体(%20 ...)。 Apparently after such conversion URL is becoming too long so HttpWebRequest truncating few last characters so instead of proper HTTP result I'm getting 404 error. 显然,在此类转换URL变得过长之后,HttpWebRequest截断了最后几个字符,因此我收到了404错误,而不是正确的HTTP结果。

Is there any way to bypass this limitation? 有什么办法可以绕过此限制?

My URL looks like this: 我的网址如下所示:

http:\\1.1.1.1\some?page=2&var=тестовое значение строки (this part can be very long)

I'm sending this as a GET since web-app I'm working with is expecting GET request at this point. 我正在以GET的形式发送此邮件,因为正在使用的网络应用目前正在期待GET请求。

The only answer to this is you have to send it in any other way as there is a limit for the length of a query string. 唯一的答案是您必须以任何其他方式发送它,因为查询字符串的长度受到限制。

The error 404 or "HTTP Error 414. The request URL is too long." 错误404或“ HTTP错误414。请求URL太长。” you'll get only because of the length of the query string as the data you are sending is longer than the limit. 您将仅由于查询字符串的长度而得到,因为您发送的数据长于限制。

refer this: http://forums.asp.net/t/1139751.aspx 请参考: http : //forums.asp.net/t/1139751.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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