2

Pretty sure I know the answer to this one, but want to make sure I'm not missing something...

Running ASP.NET 4.0 and have a request where I need to send a user to a 3rd party app but set an HTTP header value before doing so. This would be a Request header. I can set the Response Header no problem but am unable to do so with Request headers as the collection is read-only. Essentially, the process is as follows:

  1. User clicks button to initiate transfer to 3rd party app
  2. Page posts back and we grab user info - at this point I need to set the header
  3. Issue a Response.Redirect and send them to the 3rd party app.

Note: I'm not stuck on a Response.Redirect; I could change the form to POST to the 3rd party app simply as a means of transferring the user, that's fine.

I believe I could setup an IIS rewrite rule to set the header (based on this article: http://learn.iis.net/page.aspx/686/setting-http-request-headers-and-iis-server-variables/) but I don't want to go that route as the header value will contain a UserID and I'd rather not expose that to the user at all - even for a brief moment. I certainly understand that even a header isn't invisible as someone could inspect the page, but I'm not concerned with that.

Any ideas would be a great help.

Thanks, Ryan

4

1 回答 1

0

怎么样:

using System.Net;

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://www.google.com");
req.Headers.Add(new HttpRequestHeader(), "my header content");
于 2012-04-17T10:32:16.453 回答