HTTPUtility URL解码删除char

时间:2017-04-11 14:03:26

标签: c#

代码:

这种方法我使用post方法将数据发送到我的网络API:

HttpUtility.UrlEncode("email+12@domain.com")
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync(apiUrl, content);
response.EnsureSuccessStatusCode();

然后在web api方法中:

HttpContent requestContent = Request.Content;
string jsonContent = requestContent.ReadAsStringAsync().Result;
var query = HttpUtility.ParseQueryString(jsonContent);
string email = HttpUtility.UrlDecode(query.Get("email"));

结果:

  

发送电子邮件至12@domain.com

Encode方法从字符串中删除+ char,为什么?

编辑:编码前:

电子邮件+ 12%40domain.com

0 个答案:

没有答案