在c#中,HttpUtility.UrlEncode("www+mzwu+com")编码结果为www%2bmzwu%2bcom,在和Java开发的平台做对接的时候,对方用用url编码后再对其进行MD5加密,url编码之后的字符串为大(www%2Bmzwu%2Bcom)写这样加密出来的字符串就.net平台的不匹配,

以下供上方法就是解决HttpUtility.UrlEncode编码由小写转化为大写字母

public string UrlEncode(string str)
{
StringBuilder builder = new StringBuilder();
foreach (char c in str)
{
if (HttpUtility.UrlEncode(c.ToString()).Length > )
{
builder.Append(HttpUtility.UrlEncode(c.ToString()).ToUpper());
}
else
{
builder.Append(c);
}
}
return builder.ToString();
}
05-11 19:50