Solved

Cant get response.redirect to work with a query string

Posted on 2008-06-09
11
428 Views
Last Modified: 2012-05-05
Hi,

Below is an example of my query string but when I try and use response.redirect I receive 404 error but if I type this into my browser it works fine (it wont for you as I have changed the params for security reasons but the structure is the same as my live one) :-

Response.Redirect("http://www.mysite.com/folder1/folder2/LogonServer?siteID=1&user=james@mysite.com&pwd=password&destination=OS");

Any thoughts?

Thanks.

James.
0
Comment
Question by:JAMES
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 7

Expert Comment

by:ydramu
ID: 21744647
Is it only "Logonserver" or any extension it has to the page?
0
 

Author Comment

by:JAMES
ID: 21744678
To be honest I havent tried anything else with for this as we dont have any others I can test with.

We use response.redirect a lot with other "internal" .aspx pages which works fine usually though.
0
 
LVL 7

Expert Comment

by:ydramu
ID: 21744692
I mean, did you miss placing the file extension LogonServer.aspx, in query string? or you have any HTTP handlers to work with those URL formats?
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

Author Comment

by:JAMES
ID: 21744703
This is an external site not directly connected to the calling one.
0
 
LVL 7

Accepted Solution

by:
ydramu earned 500 total points
ID: 21744793
Could you please try with encoding your query string values before passing them to the url, as below.

queryString = "bob";

enQueryString = Server.URLencode(queryString);

queryString1 = "bob@test.com";

enQueryString1 = Server.URLencode(queryString1);

Response.Redirect("http://www.mysite.com/folder1/folder2/LogonServer?siteID=" + enQueryString + "&user=" + queryString1);



I gave this as example, but not as per your requirement.

And also make sure, the query string variable names, like siteID, user, etc...are matching as per the external site requirement.
0
 
LVL 7

Expert Comment

by:ydramu
ID: 21744804
One more thing, were you able to call the page url directly, which you are trying to call using Response.Redirect.

If you are able to call that page directly by accessing that, and those query string values working means, you should able to call that from Response.Redirect too.
0
 

Author Comment

by:JAMES
ID: 21744842
Hi,

Yes it works fine if i type it directly which I mentioned in my opening question :-

"if I type this into my browser it works fine "

I will try your suggestion and report back shortly.

many thanks for your help so far.
0
 

Author Comment

by:JAMES
ID: 21744958
I *think* that technically works but the destination cannot handle the encoding like that so still dont get my desired results.

Any other thoughts?
0
 
LVL 7

Expert Comment

by:ydramu
ID: 21744962
http://msdn.microsoft.com/en-us/library/zttxte6w.aspx


Try to print the total url string using Response.Write or some other way, before you try with Response.Redirect.

And verify with that url string directly using it through browser.

0
 

Author Comment

by:JAMES
ID: 21745030
You have done it!

It was my bad on your example.  I tried to encode the whole of the query string in one go (lazy me) instead of doing each param individually.  After doing this and then concatenates these strings it works great.  Maybe it's the @ in the email address on one of the params - who knows!

Anyhoo - thanks a bunch and a well deserved A.

Regards,
James.
0
 
LVL 7

Expert Comment

by:ydramu
ID: 21745039
Thank you James.
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question