Get return from url c#

Asked

Viewed 664 times

1

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

The URL returns 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 the Request.QueryString["valorTotal"] for example, it works perfectly, if I put Request.QueryString["itensContrato[0][id]"] and Request.QueryString["itensContrato[0][valorUsado]"] also works perfectly, except that this itensContract can a as may have 15, wanted some way to scroll through the url checking these values idently the amount of items you have.

Thanks in advance

Show 2 more comments

1 answer

0

To get the total of items:

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

Follow example to catch the array of values and travel them.

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

if(array != null)
{
    foreach (var valor in array)
    {
        string v = valor;
    }
}

Browser other questions tagged

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