Solved

Cant get response.redirect to work with a query string

Posted on 2008-06-09
11
421 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
  • 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
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…

840 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