Solved

Cant get response.redirect to work with a query string

Posted on 2008-06-09
11
432 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
MS Dynamics Made Instantly Simpler

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

 

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
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 …
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

717 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