Converting a Response.Redirect's URL from querystring-based to other

K

Keith Patrick

I have to do some programmatic redirects (in several pages) based on URLs I
am given from an external source. The URLs have querystrings at the end,
but one in particular is about 240 chars long, so I need to programmatically
redirect to it. Unfortunately, I can't find a way to do it. There is no
Response.Form or Response.Attributes (Request has Form and Params, but they
are read-only). I've tried using AppendHeader to pass my K/V pairs there,
but they don't show up in the Request. AppendCookie *does* work in that
way, but when I put in all the cookie K/V pairs, the length limit hits me
again, leading my Response.Redirect to inexplicably take me to my login page
once I get to around 2000+ plus chars total.
I've also tried programmatically adding hidden inputs to the page, but
Controls.Add throws an exception because some of my pages have <% %> in them
Is there a straightforward way to populate the POST header so that I can
transparently replace my querystring with posted data?
 
J

John Saunders

Keith Patrick said:
I have to do some programmatic redirects (in several pages) based on URLs I
am given from an external source. The URLs have querystrings at the end,
but one in particular is about 240 chars long, so I need to programmatically
redirect to it. Unfortunately, I can't find a way to do it. There is no
Response.Form or Response.Attributes (Request has Form and Params, but they
are read-only). I've tried using AppendHeader to pass my K/V pairs there,
but they don't show up in the Request. AppendCookie *does* work in that
way, but when I put in all the cookie K/V pairs, the length limit hits me
again, leading my Response.Redirect to inexplicably take me to my login page
once I get to around 2000+ plus chars total.
I've also tried programmatically adding hidden inputs to the page, but
Controls.Add throws an exception because some of my pages have <% %> in them
Is there a straightforward way to populate the POST header so that I can
transparently replace my querystring with posted data?

I'm not clear on what problem you're having. Are you saying that when you
do:

Response.Redirect("url-with-240-char-querystring");

That it "doesn't work"?
 
J

John Saunders

Keith Patrick said:
What I am trying to do is receive a URL witha querystring:
http://mydomain.com/MyApp?x=1&y=2&z=4..." I need to be able to say
Response.Redirect/Server.Transfer to http://mydomain.com/MyApp with the x=1,
etc. effectively POSTed in the header such that Request["x"] == 1

Sorry, you can't do that. I'm pretty sure that a Redirect is always a GET.

The best you could do would be to use WebRequest/WebResponse to POST from
your page to the destination page, and write the query string to the POST
data as form fields.
 
K

Keith Patrick

OK, but how do I do that? I can't add controls to the Controls collection,
because my page has <% %> in it, so ASP.Net regards such an action as
unsafe. So what I'm asking is, how do I a) use WebResponse (is this a
class, is this shorthand for HttpWebRespone, or WebResponse the generic HTTP
concept?, and b) how do I get access to the POST data? I seem to recall JSP
having something like Response.Attributes that I could use, but Response
only has Headers and Cookies, and neither of those are working for me.


John Saunders said:
Keith Patrick said:
What I am trying to do is receive a URL witha querystring:
http://mydomain.com/MyApp?x=1&y=2&z=4..." I need to be able to say
Response.Redirect/Server.Transfer to http://mydomain.com/MyApp with the x=1,
etc. effectively POSTed in the header such that Request["x"] == 1

Sorry, you can't do that. I'm pretty sure that a Redirect is always a GET.

The best you could do would be to use WebRequest/WebResponse to POST from
your page to the destination page, and write the query string to the POST
data as form fields.
--
John Saunders
johnwsaundersiii at hotmail


is
no hits
me
 
J

John Saunders

Keith Patrick said:
OK, but how do I do that? I can't add controls to the Controls collection,
because my page has <% %> in it, so ASP.Net regards such an action as
unsafe. So what I'm asking is, how do I a) use WebResponse (is this a
class, is this shorthand for HttpWebRespone, or WebResponse the generic HTTP
concept?, and b) how do I get access to the POST data? I seem to recall JSP
having something like Response.Attributes that I could use, but Response
only has Headers and Cookies, and neither of those are working for me.

Keith,

When I have a question like this, my first reaction is to go type
http://msdn.microsoft.com into a browser, then do a search. In this case, a
search for WebRequest found the following (among others):

..NET Framework Class Library

WebRequest Class
http://msdn.microsoft.com/library/d...f/html/frlrfSystemNetWebRequestClassTopic.asp

Accessing the Internet
http://msdn.microsoft.com/library/d...en-us/cpguide/html/cpconaccessinginternet.asp
--
John Saunders
johnwsaundersiii at hotmail

John Saunders said:
What I am trying to do is receive a URL witha querystring:
http://mydomain.com/MyApp?x=1&y=2&z=4..." I need to be able to say
Response.Redirect/Server.Transfer to http://mydomain.com/MyApp with
the
x=1,
etc. effectively POSTed in the header such that Request["x"] == 1

Sorry, you can't do that. I'm pretty sure that a Redirect is always a GET.

The best you could do would be to use WebRequest/WebResponse to POST from
your page to the destination page, and write the query string to the POST
data as form fields.
--
John Saunders
johnwsaundersiii at hotmail


I have to do some programmatic redirects (in several pages) based on
URLs
I
am given from an external source. The URLs have querystrings at the
end,
but one in particular is about 240 chars long, so I need to
programmatically
redirect to it. Unfortunately, I can't find a way to do it.
There
is in
that %>
in I
can when
you
 
K

Keith Patrick

Thanks for the links. I am aware of MSDN (and Google) and use both very,
very often. However, doing so also takes time and experimentation, so when
stuck on something like this, my first reaction (after exhausting 15 minutes
and under solutions that I am aware of) is to post to Usenet in hopes that
someone has already been down the road and possibly has code he/she can
copy/paste, while *also* going off on my own to research some more in depth
solutions. The faster I get a fix, the better, regardless of whether or not
it came from someone else or from searching through MSDN.


John Saunders said:
Keith Patrick said:
OK, but how do I do that? I can't add controls to the Controls collection,
because my page has <% %> in it, so ASP.Net regards such an action as
unsafe. So what I'm asking is, how do I a) use WebResponse (is this a
class, is this shorthand for HttpWebRespone, or WebResponse the generic HTTP
concept?, and b) how do I get access to the POST data? I seem to recall JSP
having something like Response.Attributes that I could use, but Response
only has Headers and Cookies, and neither of those are working for me.

Keith,

When I have a question like this, my first reaction is to go type
http://msdn.microsoft.com into a browser, then do a search. In this case, a
search for WebRequest found the following (among others):

.NET Framework Class Library

WebRequest Class
http://msdn.microsoft.com/library/d...f/html/frlrfSystemNetWebRequestClassTopic.asp

Accessing the Internet
http://msdn.microsoft.com/library/d...en-us/cpguide/html/cpconaccessinginternet.asp
--
John Saunders
johnwsaundersiii at hotmail

John Saunders said:
What I am trying to do is receive a URL witha querystring:
http://mydomain.com/MyApp?x=1&y=2&z=4..." I need to be able to say
Response.Redirect/Server.Transfer to http://mydomain.com/MyApp with the
x=1,
etc. effectively POSTed in the header such that Request["x"] == 1

Sorry, you can't do that. I'm pretty sure that a Redirect is always a GET.

The best you could do would be to use WebRequest/WebResponse to POST from
your page to the destination page, and write the query string to the POST
data as form fields.
--
John Saunders
johnwsaundersiii at hotmail



I have to do some programmatic redirects (in several pages)
based
on There Params,
but limit
hits page,
but
<%
that
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top