G
Guest
how to add the headers to httpwebrequest/httpwebresponse from .net code ?
Vivek said:how to add the headers to httpwebrequest/httpwebresponse from .net code ?
thanks JonJon Skeet said:Use WebRequest.Create as normal, cast it to HttpWebRequest, and use the
Headers property.
Vivek said:Ok, let me re-phrase the question here, this is what needs done:
We need to create an asp.net application, which validates a user and on
success transfers/redirects the user to another asp.net application after
adding a custom header to the request stream eg. ValidatedUserName.
When we add header to current request object and then redirect using
server.transfer() we don't get this header on the target aspx page (yes, we
tried after setting the preserve headers to true), what we think the cause
can be is that when server.transfer is called it creates a new request to the
target server and the headers that we added in the current request are not
available in that request.
We also tried adding headers in request and then getting the response after
creating a WebResponse object via WebRequest.Create(<url>) (this time it was
just a test to see if the headers were actually added when the request was
created, not redirecting as actually needed) and viola we got the header in
the target application (but this didn't helped much as what we need is a
redirect with header).
Please advice how can we do a redirect to a different webapplication by
adding custom header in request stream (there has to be a overwrite
somewhere, so that we can do what we need here).