Link to home
Create AccountLog in
Avatar of JAMES
JAMES

asked on

Cant get response.redirect to work with a query string

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.
Avatar of ydramu
ydramu
Flag of United States of America image

Is it only "Logonserver" or any extension it has to the page?
Avatar of JAMES
JAMES

ASKER

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.
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?
Avatar of JAMES

ASKER

This is an external site not directly connected to the calling one.
ASKER CERTIFIED SOLUTION
Avatar of ydramu
ydramu
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
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.
Avatar of JAMES

ASKER

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.
Avatar of JAMES

ASKER

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

Any other thoughts?
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.

Avatar of JAMES

ASKER

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.
Thank you James.