1
I have in my controller, a method where I take a Query String, I decrypt it and use the data in my query.
However, when the encrypted value has a +
, he is not recovered by Request.QueryString
. Soon I get an error when trying to decrypt.
Follow my controller:
public ActionResult
{
//Recebe a string Criptografada
string param = Request.QueryString["param"];// Nesta Parte o sinal de + não é recuperado
string nome = HttpUtility.UrlDecode(param);
//Instancia obj da DLL
Criptografia cr = new Criptografia();
//Descriptografa a string
string nomeDescrypt = cr.Decrypt(nome);// recebo o erro
//Separa a string por meio do "|"
string[] stringSeparators = new string[] { "|" };
var result = nomeDescrypt.Split(stringSeparators, StringSplitOptions.None);
//Converte para o tipo de dado correto
var matricula = Convert.ToInt32(result[0]);
var contrato = Convert.ToInt32(result[1]);
var usuarios = usuarioRepository.Lista.Where(r => r.CdMatricula == matriculaUser && r.SqContrato == contratoUser).FirstOrDefault();
return View();
}
Example of parameter passed: ./?param=kmFxK8ID3ç+Zdggbqn9oja==
What is recovered: ./?param=kmFxK8ID3ç Zdggbqn9oja==
The sign of +
vanish, and there’s a space in place.
You want to recover the signal in the param? Ex: param=foo+bar, is to return foo+bar?
– Laerte
@Laerte edited the question with what I need. That’s exactly it. " foo+bar"
– Randrade