473,836 Members | 1,999 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Response.Redire ct

Hi

I need to write a method which accepts a url (string) and redirects to it.
In addition to this I need to either (a) add a parameter to the url; or (b)
add the parameter to the header of the redirect request.

To add a parameter I guess it's as easy as adding "?myparam=myval ue" to the
url (or "&myparam=myval ue" if there already are parameters in the url string
I get).

But how do I add a header? Can I use Request.Headers .Add("myparam",
myvalue), and then do a Redirect?

Thanks,
Peter
Feb 3 '06 #1
3 5120
Peter,

When you redirect, a 302 response is sent back to the client. It is the
client that then gets the URL to redirect to, and the client which
subsequently makes the request. Because of this, you can't change the
headers that are sent.

What you want to do is call the Transfer method on the HttpServerUtili ty
(the Server property on the page, or the HttpContext) to transfer processing
to another page. You can opt to keep the form properties that were sent in
the initial request.

However, you will not be able to append any values to the Form values
sent with the request. While Form returns a NameValueCollec tion, it does
not allow you to add elements to it once it is populated.

Rather, what you should do is encode the information in the URL, or have
a key that you append to the URL which points to something in session state
that your page can retreive.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Peter Kirk" <pk@alpha-solutions.dk> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Hi

I need to write a method which accepts a url (string) and redirects to it.
In addition to this I need to either (a) add a parameter to the url; or
(b) add the parameter to the header of the redirect request.

To add a parameter I guess it's as easy as adding "?myparam=myval ue" to
the url (or "&myparam=myval ue" if there already are parameters in the url
string I get).

But how do I add a header? Can I use Request.Headers .Add("myparam",
myvalue), and then do a Redirect?

Thanks,
Peter

Feb 3 '06 #2
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> skrev i
en meddelelse news:%2******** *******@TK2MSFT NGP09.phx.gbl.. .
When you redirect, a 302 response is sent back to the client. It is
the client that then gets the URL to redirect to, and the client which
subsequently makes the request. Because of this, you can't change the
headers that are sent.

What you want to do is call the Transfer method on the
HttpServerUtili ty (the Server property on the page, or the HttpContext) to
transfer processing to another page. You can opt to keep the form
properties that were sent in the initial request.

However, you will not be able to append any values to the Form values
sent with the request. While Form returns a NameValueCollec tion, it does
not allow you to add elements to it once it is populated.

Rather, what you should do is encode the information in the URL, or
have a key that you append to the URL which points to something in session
state that your page can retreive.


Thanks for your reply. I'm not sure I can use your advice however.

Maybe if I restate the actual problem I am trying to solve, then someone can
give some advice on how to tackle it (rather than me assuming a particular
method of solving the problem).

I have a web-user-control which needs to "call" an external url (or transfer
control to that url... or whatever it is called in the web world). My
control receives some parameters from which it determines what external url
to call. My control also receives some other parameters which need to be
sent on to the external url.

The external urls expect to receive the parameters either like a "get
request": fx http://www.e-data.xx?myparam=myvalue; or they may expect to
found the parameter values in the request header.

Any advice on tackling this?
Thanks,
Peter


Feb 3 '06 #3
Peter,

In this case, you have to use the GET method to form the particular URL,
and use a redirect for the reasons I stated regarding the browser making the
request. You can't tell it what headers to send, but you can tell it the
URL to go to.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Peter Kirk" <pk@alpha-solutions.dk> wrote in message
news:u8******** *****@TK2MSFTNG P12.phx.gbl...
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> skrev i
en meddelelse news:%2******** *******@TK2MSFT NGP09.phx.gbl.. .
When you redirect, a 302 response is sent back to the client. It is
the client that then gets the URL to redirect to, and the client which
subsequently makes the request. Because of this, you can't change the
headers that are sent.

What you want to do is call the Transfer method on the
HttpServerUtili ty (the Server property on the page, or the HttpContext)
to transfer processing to another page. You can opt to keep the form
properties that were sent in the initial request.

However, you will not be able to append any values to the Form values
sent with the request. While Form returns a NameValueCollec tion, it does
not allow you to add elements to it once it is populated.

Rather, what you should do is encode the information in the URL, or
have a key that you append to the URL which points to something in
session state that your page can retreive.


Thanks for your reply. I'm not sure I can use your advice however.

Maybe if I restate the actual problem I am trying to solve, then someone
can give some advice on how to tackle it (rather than me assuming a
particular method of solving the problem).

I have a web-user-control which needs to "call" an external url (or
transfer control to that url... or whatever it is called in the web
world). My control receives some parameters from which it determines what
external url to call. My control also receives some other parameters which
need to be sent on to the external url.

The external urls expect to receive the parameters either like a "get
request": fx http://www.e-data.xx?myparam=myvalue; or they may expect to
found the parameter values in the request header.

Any advice on tackling this?
Thanks,
Peter

Feb 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3913
by: Paul | last post by:
I'm not getting the results I want when I use Response.Redirct in a ASP page. I enter this line of code in a asp page from domain1.com. Response.Redirect "http://www.domain2.com/VDIR2/table.asp" & "?PubID=" & PubID & "&PubName=" & PubName The query string is data to open a DB. the page displays
6
4330
by: Sam | last post by:
I have some issues with HTTP Headers and I was hoping for some pointers or references to good articles. Here is the problem. I have 6 .aspx pages, each page contains a common .ascx. This ascx serves two purposes, 1. it contains a tab strip with response.redirects to navigate to the other pages; 2. I authenticate the user by check to see if a cookie exists, if it doesn't I redirect to a login screen.
5
4576
by: venner | last post by:
I'm having an issue with an ASP.NET website after upgrading to ASP.NET 2.0. The website makes use of a central authentication service (CAS) provided at the university I work for. Each page checks a session variable, and if it is not present, does a Response.Redirect to a webpage for the CAS passing a url parameter for the url to post back to. The CAS provides a page for the user to log into, validates the username and password, and then...
4
11444
by: mike.biang | last post by:
I have an ASP page that is using an XMLHTTP object to request various pages from my server. I keep a single session throughout the XMLHTTP requests by bassing the ASPSESSIONID cookie through the XMLHTTP object. However, when the page requested through the XML object makes a <%Response.Redirect()%> call, a new session is created each time. Is this a flaw in the XMLHTTP Object? How can I force the session to remain the same after a...
9
4356
by: RN1 | last post by:
When a server encounters the line Response.Redirect("abcd.asp") in a ASP script, the server tells the browser that it has to be redirected to another page (which is abcd.asp, in this case). The browser then makes a new request to the server to redirect itself to abcd.asp after which the user gets redirected to abcd.asp. But in case of Server.Execute (or Server.Transfer), when the server
0
9820
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9670
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10844
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10548
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6979
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5649
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4452
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.