Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
can we use querystring in server.transfer?help?
Posted 27-Jun-12 2:34am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Yes we can.
 
I tried this and it worked.
 
default.aspx.cs
protected void Page_Load(object sender, EventArgs e)
   {
       Server.Transfer("DEfault6.aspx?id=5");
   }
 

default6.aspx.cs
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.
  Permalink  
Comments
Member 9027346 at 27-Jun-12 8:10am
   
Thanks:)
Rahul Rajat Singh at 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 at 27-Jun-12 8:20am
   
Good Answer 5+
Rate this: bad
good
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.
  Permalink  
v2
Comments
Rahul Rajat Singh at 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 at 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 at 27-Jun-12 8:12am
   
Thanks. Good to know. Updated answer to point it out.
Rahul Rajat Singh at 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
0 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 479
2 Maciej Los 305
3 Mathew Soji 195
4 Richard MacCutchan 145
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,712
2 DamithSL 5,461
3 Manas Bhardwaj 4,916
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 27 Jun 2012
Copyright © CodeProject, 1999-2014
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