How do I hide or clear the url when I get Asp.net mvc?

Asked

Viewed 380 times

0

I wanted to know how to clean or hide data that I pass through a URL to a webapi so that the data n become apparent and do not disturb my routes..

following example: http://localhost:65286/Cliente/Login?Email=alguem%40gmail.com&Password=123123123

       public IActionResult Login(string Email, string Password)
    {
        HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, BaseUrlFuncionario + "/Login/"+ Email +"/"+ Password);

        HttpResponseMessage response = HttpInstance.GetHttpClientInstance().SendAsync(request).Result;

        Funcionario funcionario = new Funcionario();

        string l = response.Content.ReadAsStringAsync().Result;
        funcionario = JsonConvert.DeserializeObject<Funcionario>(l);

        if (response.IsSuccessStatusCode)
        {
            TempData["Funcionario"] = funcionario;
            return View("Principal", TempData);
        }
        else
        {
            return BadRequest();
        }

    }
  • By what you wrote, you are making 'GET' requests for login validation. It has how to publish your code that calls the API?

  • I edited the question by inserting my method

  • the API is yours, can you change its code? : new HttpRequestMessage(HttpMethod.Post, BaseUrlFuncionario + "/Login/"+ Email +"/"+ Password);. But your api has to be ready to receive POST and not GET requests

  • Thanks, I changed everything to post and it worked!!!

  • If everything worked, mark as answered, will help those next who view the question

1 answer

1


Change the method from GET to POST and I believe it will solve your problem

Browser other questions tagged

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