1

I am doing like this in pageload method

Request.QueryString.Add("Filter_DateRange", "yesterday");
Request.QueryString.Add("Filter_FormType", "10-K");

but it is giving an exception

"Collection is readonly".

Any way to do this?

walther
  • 13,466
  • 5
  • 41
  • 67
Elvin
  • 2,131
  • 8
  • 23
  • 25
  • Why would you want to do this? Btw, don't tag asp.net questions with asp-classic tag, it's a completely different thing. – walther Aug 17 '12 at 06:57
  • 1
    Read this question - http://stackoverflow.com/questions/4968731/why-is-request-querystring-readonly – Buzz Aug 17 '12 at 07:05
  • 1
    No one said it is, that's why it's a comment! I asked you something, because what you're trying to do is a... well, how to put it in a polite way. You can't modify the querystring, because you're already on a server-side. Maybe if you provide more context, we'd be able to actually help you resolve your problem in a different way....... – walther Aug 17 '12 at 07:06
  • @walther the link to project will always be called with some parameters.I need it for testing purpose as right now I cant deploy the site on IIS. – Elvin Aug 17 '12 at 07:12

2 Answers2

1

Based on the comments, there are some options to choose from to suit your needs...

For instance, you can abstract (and clearly should) the process of retrieving the values directly from a querystring and implement some kind of a layer, that does it for you. You can then swap this layer freely without worrying about breaking your app. The most basic approach to do this is to implement page properties. In your code you won't directly call Request.QueryString..., but instead you'll be working with these properties. When you'll want to change the source of your values, just change a property accordingly.

Another approach might be to create links you want to test and you can even place those links on a separate page, for instance testlinks.aspx. That way you can have things nicely organized for testing purposes.

And so on.

walther
  • 13,466
  • 5
  • 41
  • 67
0

If you want to simulate the request object for automated testing i reccomend you look into Moles.

If you just want to manually test, why not just create a link with the query string params you need?

Michael Christensen
  • 1,768
  • 1
  • 13
  • 11