Why is Request.QueryString readonly?

I thought you couldn't change the QueryString on the server without a redirect.

But this code works* for me:

Request.QueryString edit

I'm so amazed.

So here are my questions regarding this:

  1. Why is Request.QueryString readonly?
  2. Why does this code/hack work*?
  3. How safe is it, if you change to readonly as soon as you are done editing, both regarding bad errors or unexpected behaviour, and regarding maintaining and understanding the code?
  4. Where in the event cycle would it make most sense to do this crazy edit if you are only using PageLoad and OnPageRender?

*More details:

I have a page with items that are grouped into tabs. Each tab is an asp:LinkButton

I want to be able to link directly to a specific tab. I do that with a QueryString parameter 'tab=tabName'. It works. But when I then click a new tab, the querystring is still in the Url, and thus the tab specified in the Querystring gets activated and not the one I clicked.

By using Request.QueryString edit this does not happen. Then my solution 'works'.

Thanks in advance.

5
задан Community 23 May 2017 в 12:02
поделиться