Main Site Documentation

Adding a response headering using HttpListenerResponse object


#1

I’m trying to do some networking with my Panda II and the FEZ Connect shield. I’ve found that having a locally running HTML file and JavaScript has problems getting data via jQuery from my device. I need to add the following header to my responses:

I cannot, however figure out how to add this to my response object. There’s an “add()” method that shows up in Visual Studio, but I can’t find in the documentation. The online documentation doesn’t have ANY information I can find about how to add the header, and just shows a “get()” and a “set()” method: http://www.ghielectronics.com/downloads/NETMF/WIZnet%20Library%20Documentation/html/f4fd09d1-8db8-44c2-dc62-590174f1494a.htm

What should I do here?


#2

@ gallamine
I’ve used this recently to add “location” header to my response, but I’m at work now and don’t remember the exact syntax I used. I believe I did this:

myResponse.Headers["<my header name>"] = "<my header value>";

#3

I ended up using this function:

response.Headers.Add("Access-Control-Allow-Origin: *");

Sadly, the “add()” method is undocumented. That was frustrating.

When will there be the option of leaving comments on the documentation webpage? That would be helpful!


#4

@ gallamine It is documented.

If you click here to see the “Headers” property of HttpListenerRequest:
http://www.ghielectronics.com/downloads/NETMF/WIZnet%20Library%20Documentation/Index.html

And then click on the “WebHeaderCollection” base class link:
http://www.ghielectronics.com/downloads/NETMF/WIZnet%20Library%20Documentation/Index.html

And then click the “WebHeaderCollection Members” link, you will find the documentation you are looking for.