Get return from url c #

1

I need to get a return from an ajax that I send.

The URL returns me something like: http://localhost:11910/ProtocoloExterno/Inserir?itensContrato%5B0%5D%5Bid%5D=1&itensContrato%5B0%5D%5BvalorUsado%5D=15110%2C10&itensContrato%5B1%5D%5Bid%5D=2&itensContrato%5B1%5D%5BvalorUsado%5D=111%2C00&contrato=4100001060&codigoParceiro=7900321&nomeParceiro=MTN%20AFGHANISTAN&areaReclamacao=&codigoPatrimonial=4000014000&operadora=Fixo&statusObra=bis&nFRN=1011000510&endereco=Rua%20Ursulina%20de%20Melo&estado=AL&cidade=1651&descItem=Descricao%20de%20teste&icms=1&ipi=10&contaContabil=Capital%20n%C3%A3o%20chamado&ordemInterna=15101000&quantidade=10&valorUnitario=15221%2C10&valorTotal=15221%2C10&numeroPedido=100040&itemPedido=10&observacao=

When I put Request.QueryString["valorTotal"] for example, it works perfectly, if I put Request.QueryString["itensContrato[0][id]"] and Request.QueryString["itensContrato[0][valorUsado]"] it also works perfectly, except that this items can be a contract like 15, I wanted some way to go through the url verifying these values idependetemente of the amount of items that have.

Thank you in advance

    
asked by anonymous 01.06.2018 / 18:54

1 answer

0

To get total items:

int? total  = Request.QueryString.GetValues("itensContrato")?.Count();

Here's an example to get the array values and scroll through them.

string[] array = Request.QueryString.GetValues("itensContrato");

if(array != null)
{
    foreach (var valor in array)
    {
        string v = valor;
    }
}
    
04.06.2018 / 19:03