?
Solved

Cant get response.redirect to work with a query string

Posted on 2008-06-09
11
Medium Priority
?
434 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month12 days, 15 hours left to enroll

777 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