Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Accessing HTTP Headers from WebService


I have a simple webservice written in C#.  It is being called from a webpage via HTTP POST using an HTTPTransaction (from XMLHTTP).

I would like to be able to set a value in the response header that indicates if an error has occurred.  I'm using code like this:

  StringWriter oWriter = new StringWriter();
  HttpResponse oResp = new HttpResponse(oWriter);
  oResp.AppendHeader("test","value");
  oResp.Flush();

However, when I look at the response headers returned by the transaction, by header is not included?

Am I doing something incredibly stupid?  Or am I just overlooking something very simple?

Jason
Tuesday, October 22, 2002

Try this:
Context.Response.AddHeader("CWTest", "Hallo");

Works like a champ.

Cheers,
Christian Weyer
[MVP ASP.NET | AspElite Member]
** http://www.xmlwebservices.cc/
*  .NET XML Web Services Repertory

Christian Weyer
Tuesday, October 22, 2002


You, sir, are a genius.  Thanks!

Is there some sort of magic 8-ball you can get that will tell you which of the 10-billion .NET framework objects is the right one for your particular problem?  I'd pay for that.

Jason
Tuesday, October 22, 2002

What do you exactly mean? There is the Framework SDK docs which sould be enough ...
And then there are myriads of online resources ;-)

Cheers,
Christian
[MVP ASP.NET | AspElite Member]
** http://www.xmlwebservices.cc/
*  .NET XML Web Services Repertory

Christian Weyer
Wednesday, October 23, 2002

*  Recent Topics

*  Fog Creek Home