Passing data encrypted by URL in ASP.NET MVC

3

I need to pass a link, but I did not want to leave it too exposed, I would like to know how to Encrypt at least the id of the object. I created a class for Cryptography, but it generates "/" and this places it as a route in MVC.

    
asked by anonymous 28.09.2015 / 22:08

2 answers

2

Continue using your encryption in the parameters, but to avoid problems with characters not allowed in the Url, before sending the string, use the HttpContext.Current.Server.UrlEncode () .

When re-reading the string, use the HttpContext.Current.Server .UrlDecode () .

When you are outside an ASP.NET application, if you are using Framework 4.5 onwards, it is best to use the WebUtility to access the UrlEncode and UrlDecode methods.

    
28.09.2015 / 22:28
0

Use:

Regex regex1 = new Regex("/");
string result = rgx.Replace('SEU TEXTO CRIPTOGRAFADO', 'QUALQUER SIMBOLO QUE NÃO É USADO E NÃO CAUSA PROBLEMAS';

Then add the result to the URL and at the time of converting use:

Regex regex1 = new Regex('SIMBOLO USADO');
string result = rgx.Replace('SEU TEXTO CRIPTOGRAFADO E CODIFICADO', "/";

Another way would be to use POST, which would make your site more secure. This encryption does not seem very secure, it would be good to search for an existing encryption class if you want more security.

    
29.09.2015 / 03:41