1

I have a URL like so api/getListItems?data=false

how would I get the query parameter data? I tried using Request.QueryString but I get an error 'The type or namespace name 'Request' could not be found' I have the System.Web referenced installed, the version is 4.0.0.0 and the .NET Framework is 4.5...is there something I am missing?

Thanks,

3
  • 5
    show your code... Request.QueryString should be populated if your code is in the correct spot. Commented Aug 11, 2014 at 19:52
  • 1
    Is getListItems a WebForms Page (aspx) or an HttpHandler (ashx) or MVC? Commented Aug 11, 2014 at 19:54
  • maybe Request["data"] works for you, check it. Commented Aug 11, 2014 at 19:55

2 Answers 2

2

This is how I read data from querystrig:

bool Data = Boolean.Parse(System.Web.HttpContext.Current.Request.QueryString["data"]);
Sign up to request clarification or add additional context in comments.

Comments

0

you can also do this :

string url = HttpContext.Current.Request.Url.AbsoluteUri;

String data= url.Split('?')[1].Split('=')[1];

thanks

2 Comments

this works, but data now equals data=false, how do i get false?
see edit just now I've split using ('=') to get the False, I mean if you have data equals data=false, then just do this string dataValue=data.Split('=')[1]; //this would give you False

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.