简体   繁体   English

ASP.NET Webforms和URL编码

[英]ASP.NET Webforms and URL encoding

I'm having issues with GET parameters and ASP.NET. 我在GET参数和ASP.NET方面遇到问题。 I've got one parameter with a value which has non-ASCII characters ( "Físico" ). 我有一个参数,其值包含非ASCII字符( “Físico” )。 When ASP.NET generates the form, it has the action set to 当ASP.NET生成表单时,它的操作设置为

<form method="post" action="SomePage.aspx?query=F%u00edsico">

It doesn't seem like the string is being properly URL encoded by ASP.NET. 看起来该字符串不是由ASP.NET正确地URL编码的。 This is causing issues with jQuery UI ("malformed URI"). 这导致jQuery UI(“格式错误的URI”)出现问题。 Am I missing anything? 我有什么想念的吗? Shouldn't the browser be properly encoding the URL and shouldn't ASP.NET properly encode it when it generates the form? 浏览器是否应该正确编码URL,ASP.NET生成表单时是否应该正确编码URL?

Try this on the Page_Load event as a work around: 尝试在Page_Load事件上解决此问题:

Vb.Net Vb.Net

Dim unicode As UnicodeEncoding = New UnicodeEncoding
form1.Action = unicode.GetString(unicode.GetBytes(Request.Url.ToString()))

c# C#

UnicodeEncoding unicode = new UnicodeEncoding();
form1.Action = unicode.GetString(unicode.GetBytes(Request.Url.ToString()));

that query string is being encoded to unicode because of the tilde in the í 该查询字符串由于í中的波浪号而被编码为unicode

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

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