Click here to Skip to main content
13,052,669 members (63,967 online)
Rate this:
Please Sign up or sign in to vote.
See more:
can we use querystring in server.transfer?help?
Posted 27-Jun-12 1:34am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Yes we can.

I tried this and it worked.

protected void Page_Load(object sender, EventArgs e)

protected void Page_Load(object sender, EventArgs e)
        string s = Request.QueryString["id"] as string;

an the value of s was 5 after i ran it.
Member 9027346 27-Jun-12 8:10am
Rahul Rajat Singh 27-Jun-12 8:12am
you are welcome.

P.S. I think your other question similar onewith the cross page also has an answer. for that question if it worked then please mark the answer as solution as this would let other know that the problems is solved and the others with similar problem can also refer and benefit from it.
vangapallynaveen 27-Jun-12 8:20am
Good Answer 5+
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

You cannot pass new querystring in Server.Transfer.
The Transfer method preserves the QueryString and Form collections. Thus if any existing querystrings were there then it will pass on.

Refer: MSDN: HttpServerUtility.Transfer Method (String)[^]

UPDATE: As Rahul already tested it out, it looks like one can pass querystring in Server.Transfer even though documentation does not states so. But, to it, I am sure URL will not change in the browser.
Rahul Rajat Singh 27-Jun-12 8:00am
I beg to differ here. try the code in my solution. it will work.

The real question is should we do this. and the answer to that would be no.
Rahul Rajat Singh 27-Jun-12 8:03am
The only thing is that the USER will never be able to pass this query string from browser. as the browser url is not changed in user browser.
Sandeep Mewara 27-Jun-12 8:12am
Thanks. Good to know. Updated answer to point it out.
Rahul Rajat Singh 27-Jun-12 8:15am
you are welcome. and yes you are right the URL will not change.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 27 Jun 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100