2013-08-16 45 views
1

我遇到了GET参数和ASP.NET问题。我有一个参数,其值非ASCII字符(“Físico”)。当ASP.NET生成表单时,它的动作设置为ASP.NET Webforms和URL编码

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

似乎并不像ASP.NET正确地对URL进行URL编码。这导致了jQuery UI(“格式错误的URI”)的问题。我错过了什么?浏览器不应该正确编码URL,并且不应该在生成表单时正确编码它?

+0

显示您用于生成表单操作的代码。 –

+0

我不生成表单的动作,我只是链接到SomePage.aspx?query =Físico。 ASP.NET然后生成它的'表单(像往常一样)。 – stelonix

+0

明白了,能够重现这个问题。 –

回答

1

Page_Load事件试试这个作为一个变通:

Vb.Net

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

C#

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

该查询字符串被编码为Unicode,因为代码í