I have in my controller, a method where I get a Query String , decrypt it and use the data in my query.
However, when the encrypted value has a +
sign, it is not recovered by Request.QueryString
. I soon get an error 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();
}
What is retrieved: Parameter example passed: ./?param=kmFxK8ID3ç ZdGGbQN9oJA ==
The sign of +
disappears, and space is left in place.