Encrypt data between Controller Asp.Net Mvc and Jquery Ajax

Asked

Viewed 32 times

0

I communicate between Back and Front End with Ajax, but I don’t know how to encrypt the data transported, this is a method of my controller that returns a Json I call through the Ajax:

[HttpGet]
[Route("/atividades/ListarWmsAtividadeId/{IdWmsAtividade}")]
public IActionResult ListarWmsAtividadeId(int IdWmsAtividade)
{
    var wmsatividade = new wmsatividade();

    wmsatividade = _wmsatividadeRepositorio.ListarId(IdWmsAtividade);

    if (wmsatividade == null)
       return Json(new { validarequisicao = "wmsatividade não encontrado" });

    return Json(wmsatividade);
}

This is my method in front end to call the method

$.ajax(
{
    type: stipo,
    url: surl + parametros,
    contentType: "application/json; charset=utf-8",            
    dataType: "json",
    async: false,
    success: function (dados)
    {
        if (dados.hasOwnProperty('validarequisicao'))
        {
            MensagemTextDanger(dados.validarequisicao, scampo);
            retorno = dados
        }
        else
        {
            if (dados != null)
                retorno = dados;                  
        }
    },
    error: function ()
    {
        MensagemTextDanger('Erro requisição ' + sorigem,scampo)
    }
});

The code is functional, but in the console you can see the contents inside the file Json, and I need to encrypt that data.

  • I don’t understand why it’s normal behavior.

  • @Virgilionovic, I’m pretty new to technology, so maybe the doubt is meaningless. But when I make a select bringing a filled class like the one of the question, the user if he has a little knowledge, can inspect and see the data of the return of the select, is correct this way same?

  • When it is done so, you have the possibility to check the return and the browser console brings this information. It’s normal behavior, it’s like that, now security factor, encryption etc... it’s another matter. Be careful not to return sensitive data such as user passwords (never), now data that will appear on the user screen is no problem if they are not as I said sensitive

  • 1

    I got it, perfect in case there really are no problems, but it’s clear that sensitive data should be hidden.. i come from desktop applications(Delphi) for me some concepts are still very different and cloudy, thanks for the help @Virgilionovic

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.