bom dia a todos, tenha uma sequencia na URL que recebo por QueryString, porém o caracter "+" qdo faço o encode assume o valor correto hexadecimal "%2b", mas qdo faco o decode esse caracter "+" vira "espaço", preciso que ele fique como "+" e não "espaço". Segue abaixo o codigo que estou usando.
pagina.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="pagina3.aspx.cs" Inherits="pagina3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>HttpUtility Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
The raw url is: <br />
<asp:Label id="UrlRawOutput"
runat="server" />
<br /><br />
The url encoded is: <br />
<asp:Label id="UrlEncodedOutput"
runat="server" />
<br /><br />
The url decoded is: <br />
<asp:Label id="UrlDecodedOutput"
runat="server" />
<br /><br />
The query string NameValueCollection is: <br />
<asp:Label id="ParseOutput"
runat="server" />
</div>
</form>
</body>
</html>
pagina.aspx.cs
using System;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class pagina3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String currurl = HttpContext.Current.Request.RawUrl;
String querystring = null;
// Check to make sure some query string variables
// exist and if not add some and redirect.
int iqs = currurl.IndexOf('?');
if (iqs == -1)
{
String redirecturl = currurl + "?email=mAKq7tfZb9zufXHN5TyPMAxNgQhaTjbtPiidyqdXSBA=&valor=XOCf2J+PiAVo5SBiYbly2w==";
Response.Redirect(redirecturl, true);
}
// If query string variables exist, put them in
// a string.
else if (iqs >= 0)
{
querystring = (iqs < currurl.Length - 1) ? currurl.Substring(iqs + 1) : String.Empty;
}
// Parse the query string variables into a NameValueCollection.
NameValueCollection qscoll = HttpUtility.ParseQueryString(querystring);
// Iterate through the collection.
StringBuilder sb = new StringBuilder();
foreach (String s in qscoll.AllKeys)
{
sb.Append(s + " - " + qscoll[s] + "<br />");
}
// Write the results to the appropriate labels.
ParseOutput.Text = sb.ToString();
UrlRawOutput.Text = currurl;
UrlEncodedOutput.Text = HttpUtility.UrlEncode(currurl);
UrlDecodedOutput.Text = HttpUtility.UrlDecode(currurl);
}
}
se alguém puder me ajudar.
obrigado.