1

I have Json file in string (for example):

@{
"Url": "http://site.com/?q=windows8"
}

How can i take the information after ?q= on c# (windows 8). Sorry for my English.

xanatos
  • 109,618
  • 12
  • 197
  • 280
user2660964
  • 141
  • 1
  • 9

2 Answers2

2

You can use the querystring.

in Codebehind file

public String q
{
    get
    {
        if (Request.QueryString["q"] == null)
            return String.Empty;
        return Convert.ToString(Request.QueryString["q"]);
    }
}

then use the line below to get the value

var index = ('<%=q%>');
Marco
  • 22,856
  • 9
  • 75
  • 124
saun4frsh
  • 383
  • 1
  • 4
  • 21
1

You can do simply this :

string s = "myURL/?q=windows8";

// Loop through all instances of ?q=
int i = 0;
while ((i = s.IndexOf("?q=", i)) != -1)
{

    // Print out the substring. Here : windows8
    Console.WriteLine(s.Substring(i));

    // Increment the index.
    i++;
}
Olivier Albertini
  • 684
  • 2
  • 6
  • 22