-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
HttpListenerResponse.xml
1520 lines (1379 loc) · 85.3 KB
/
HttpListenerResponse.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<Type Name="HttpListenerResponse" FullName="System.Net.HttpListenerResponse">
<TypeSignature Language="C#" Value="public sealed class HttpListenerResponse : IDisposable" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit HttpListenerResponse extends System.Object implements class System.IDisposable" />
<TypeSignature Language="DocId" Value="T:System.Net.HttpListenerResponse" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class HttpListenerResponse
Implements IDisposable" />
<TypeSignature Language="F#" Value="type HttpListenerResponse = class
 interface IDisposable" />
<TypeSignature Language="C++ CLI" Value="public ref class HttpListenerResponse sealed : IDisposable" />
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Net.HttpListener</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<TypeForwardingChain>
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Net.HttpListener" ToVersion="5.0.0.0" FrameworkAlternate="net-5.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Net.HttpListener" ToVersion="6.0.0.0" FrameworkAlternate="net-6.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Net.HttpListener" ToVersion="7.0.0.0" FrameworkAlternate="net-7.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Net.HttpListener" ToVersion="8.0.0.0" FrameworkAlternate="net-8.0" />
<TypeForwarding From="netstandard" FromVersion="2.1.0.0" To="System.Net.HttpListener" ToVersion="9.0.0.0" FrameworkAlternate="net-9.0" />
</TypeForwardingChain>
<Base>
<BaseTypeName>System.Object</BaseTypeName>
</Base>
<Interfaces>
<Interface>
<InterfaceName>System.IDisposable</InterfaceName>
</Interface>
</Interfaces>
<Attributes>
<Attribute FrameworkAlternate="net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.Nullable(0)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.Nullable(0)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.NullableContext(1)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.NullableContext(1)>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Represents a response to a request being handled by an <see cref="T:System.Net.HttpListener" /> object.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When a client makes a request for a resource handled by an <xref:System.Net.HttpListener> object, the request and response are made available to your application in an <xref:System.Net.HttpListenerContext> object. The request is represented by an <xref:System.Net.HttpListenerRequest> object and is available in the <xref:System.Net.HttpListenerContext.Request%2A?displayProperty=nameWithType> property. The response is represented by an <xref:System.Net.HttpListenerResponse> object and is available in the <xref:System.Net.HttpListenerContext.Response%2A?displayProperty=nameWithType> property.
You can customize the response by setting various properties, such as <xref:System.Net.HttpListenerResponse.StatusCode%2A>, <xref:System.Net.HttpListenerResponse.StatusDescription%2A>, and <xref:System.Net.HttpListenerResponse.Cookies%2A>. Use the <xref:System.Net.HttpListenerResponse.OutputStream%2A?displayProperty=nameWithType> property to obtain a <xref:System.IO.Stream> instance to which response data can be written. Finally, send the response data to the client by calling the <xref:System.Net.HttpListenerResponse.Close%2A> method.
]]></format>
</remarks>
<altmember cref="T:System.Net.HttpListener" />
<altmember cref="T:System.Net.HttpListenerContext" />
<altmember cref="T:System.Net.HttpListenerRequest" />
</Docs>
<Members>
<Member MemberName="Abort">
<MemberSignature Language="C#" Value="public void Abort ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Abort() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Net.HttpListenerResponse.Abort" />
<MemberSignature Language="VB.NET" Value="Public Sub Abort ()" />
<MemberSignature Language="F#" Value="member this.Abort : unit -> unit" Usage="httpListenerResponse.Abort " />
<MemberSignature Language="C++ CLI" Value="public:
 void Abort();" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Net.HttpListener</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="net-5.0">
<AttributeName Language="C#">[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Closes the connection to the client without sending a response.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Calling this method on an object that has already been closed has no effect. If the response has not already been closed, this method closes it and the associated <xref:System.Net.HttpListenerRequest> and <xref:System.Net.HttpListenerContext> objects. The connection to the client is also closed, regardless of the <xref:System.Net.HttpListenerRequest.KeepAlive%2A> property value of the client request.
]]></format>
</remarks>
<altmember cref="T:System.Net.HttpListener" />
<altmember cref="T:System.Net.HttpListenerContext" />
<altmember cref="T:System.Net.HttpListenerRequest" />
</Docs>
</Member>
<Member MemberName="AddHeader">
<MemberSignature Language="C#" Value="public void AddHeader (string name, string value);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void AddHeader(string name, string value) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Net.HttpListenerResponse.AddHeader(System.String,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub AddHeader (name As String, value As String)" />
<MemberSignature Language="F#" Value="member this.AddHeader : string * string -> unit" Usage="httpListenerResponse.AddHeader (name, value)" />
<MemberSignature Language="C++ CLI" Value="public:
 void AddHeader(System::String ^ name, System::String ^ value);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Net.HttpListener</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="name" Type="System.String" />
<Parameter Name="value" Type="System.String" />
</Parameters>
<Docs>
<param name="name">The name of the HTTP header to set.</param>
<param name="value">The value for the <paramref name="name" /> header.</param>
<summary>Adds the specified header and value to the HTTP headers for this response.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Calling this method is equivalent to calling the <xref:System.Net.WebHeaderCollection.Set%2A> method on the collection returned by the <xref:System.Net.HttpListenerResponse.Headers%2A> property.
If the header specified in `name` does not exist, this method inserts a new header into the <xref:System.Net.HttpListenerResponse.Headers%2A> property's collection. If `name` is present in the collection, this method replaces the existing value with `value`. To add a value to an existing header without replacing the existing value, use the <xref:System.Net.HttpListenerResponse.AppendHeader%2A> method.
## Examples
The following code example demonstrates adding a header using this property.
:::code language="csharp" source="~/snippets/csharp/System.Net/HttpListener/Overview/test.cs" id="Snippet26":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Net_Listener_Basic/VB/test.vb" id="Snippet26":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="name" /> is <see langword="null" /> or an empty string ("").</exception>
<exception cref="T:System.ArgumentException">You are not allowed to specify a value for the specified header.
-or-
<paramref name="name" /> or <paramref name="value" /> contains invalid characters.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">.NET Framework and .NET Core versions 2.0 - 3.1 only: The length of <paramref name="value" /> is greater than 65,535 characters.</exception>
<altmember cref="T:System.Net.HttpListener" />
<altmember cref="T:System.Net.HttpListenerContext" />
<altmember cref="T:System.Net.HttpListenerRequest" />
<altmember cref="T:System.Net.WebHeaderCollection" />
</Docs>
</Member>
<Member MemberName="AppendCookie">
<MemberSignature Language="C#" Value="public void AppendCookie (System.Net.Cookie cookie);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void AppendCookie(class System.Net.Cookie cookie) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Net.HttpListenerResponse.AppendCookie(System.Net.Cookie)" />
<MemberSignature Language="VB.NET" Value="Public Sub AppendCookie (cookie As Cookie)" />
<MemberSignature Language="F#" Value="member this.AppendCookie : System.Net.Cookie -> unit" Usage="httpListenerResponse.AppendCookie cookie" />
<MemberSignature Language="C++ CLI" Value="public:
 void AppendCookie(System::Net::Cookie ^ cookie);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Net.HttpListener</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="cookie" Type="System.Net.Cookie" />
</Parameters>
<Docs>
<param name="cookie">The <see cref="T:System.Net.Cookie" /> to add to the collection to be sent with this response.</param>
<summary>Adds the specified <see cref="T:System.Net.Cookie" /> to the collection of cookies for this response.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Calling this method is equivalent to calling the <xref:System.Net.CookieCollection.Add%2A> method on the collection returned by the <xref:System.Net.HttpListenerResponse.Cookies%2A> property.
If the specified cookie does not exist in the <xref:System.Net.HttpListenerResponse.Cookies%2A> property's collection, `cookie` is added. If the cookie exists in the collection, `cookie` replaces it.
## Examples
The following code example demonstrates adding a cookie to a response
:::code language="csharp" source="~/snippets/csharp/System.Net/HttpListener/Overview/test.cs" id="Snippet20":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Net_Listener_Basic/VB/test.vb" id="Snippet20":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="cookie" /> is <see langword="null" />.</exception>
<altmember cref="T:System.Net.HttpListener" />
<altmember cref="T:System.Net.HttpListenerContext" />
<altmember cref="T:System.Net.HttpListenerRequest" />
</Docs>
</Member>
<Member MemberName="AppendHeader">
<MemberSignature Language="C#" Value="public void AppendHeader (string name, string value);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void AppendHeader(string name, string value) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Net.HttpListenerResponse.AppendHeader(System.String,System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub AppendHeader (name As String, value As String)" />
<MemberSignature Language="F#" Value="member this.AppendHeader : string * string -> unit" Usage="httpListenerResponse.AppendHeader (name, value)" />
<MemberSignature Language="C++ CLI" Value="public:
 void AppendHeader(System::String ^ name, System::String ^ value);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Net.HttpListener</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="name" Type="System.String" />
<Parameter Name="value" Type="System.String" />
</Parameters>
<Docs>
<param name="name">The name of the HTTP header to append <paramref name="value" /> to.</param>
<param name="value">The value to append to the <paramref name="name" /> header.</param>
<summary>Appends a value to the specified HTTP header to be sent with this response.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Calling this method is equivalent to calling the <xref:System.Net.WebHeaderCollection.Add%2A> method on the collection returned by the <xref:System.Net.HttpListenerResponse.Headers%2A> property.
If the header specified in `header` does not exist, this method inserts a new header into the <xref:System.Net.HttpListenerResponse.Headers%2A> property's collection. If `header` is present in the collection, this method adds `value` to the existing values. To replace the value of an existing header, use the <xref:System.Net.HttpListenerResponse.AddHeader%2A> method.
]]></format>
</remarks>
<exception cref="T:System.ArgumentException">
<paramref name="name" /> is <see langword="null" /> or an empty string ("").
-or-
You are not allowed to specify a value for the specified header.
-or-
<paramref name="name" /> or <paramref name="value" /> contains invalid characters.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">.NET Framework and .NET Core versions 2.0 - 3.1 only: The length of <paramref name="value" /> is greater than 65,535 characters.</exception>
<altmember cref="T:System.Net.HttpListener" />
<altmember cref="T:System.Net.HttpListenerContext" />
<altmember cref="T:System.Net.HttpListenerRequest" />
</Docs>
</Member>
<MemberGroup MemberName="Close">
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Sends the response to the client and releases the resources held by this <see cref="T:System.Net.HttpListenerResponse" /> instance.</summary>
</Docs>
</MemberGroup>
<Member MemberName="Close">
<MemberSignature Language="C#" Value="public void Close ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Close() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Net.HttpListenerResponse.Close" />
<MemberSignature Language="VB.NET" Value="Public Sub Close ()" />
<MemberSignature Language="F#" Value="member this.Close : unit -> unit" Usage="httpListenerResponse.Close " />
<MemberSignature Language="C++ CLI" Value="public:
 void Close();" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Net.HttpListener</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="net-5.0">
<AttributeName Language="C#">[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Sends the response to the client and releases the resources held by this <see cref="T:System.Net.HttpListenerResponse" /> instance.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method closes the response stream and the <xref:System.Net.HttpListenerRequest> associated with the response.
## Examples
The following code example demonstrates calling this method to send a <xref:System.Net.HttpStatusCode.Forbidden> (403) response to the client.
:::code language="csharp" source="~/snippets/csharp/System.Net/AuthenticationSchemes/Overview/sample.cs" id="Snippet5":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLListener/vb/sample.vb" id="Snippet5":::
]]></format>
</remarks>
<altmember cref="T:System.Net.HttpListener" />
<altmember cref="T:System.Net.HttpListenerContext" />
<altmember cref="T:System.Net.HttpListenerRequest" />
</Docs>
</Member>
<Member MemberName="Close">
<MemberSignature Language="C#" Value="public void Close (byte[] responseEntity, bool willBlock);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Close(unsigned int8[] responseEntity, bool willBlock) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Net.HttpListenerResponse.Close(System.Byte[],System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Sub Close (responseEntity As Byte(), willBlock As Boolean)" />
<MemberSignature Language="F#" Value="member this.Close : byte[] * bool -> unit" Usage="httpListenerResponse.Close (responseEntity, willBlock)" />
<MemberSignature Language="C++ CLI" Value="public:
 void Close(cli::array <System::Byte> ^ responseEntity, bool willBlock);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Net.HttpListener</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="net-5.0">
<AttributeName Language="C#">[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="responseEntity" Type="System.Byte[]" />
<Parameter Name="willBlock" Type="System.Boolean" />
</Parameters>
<Docs>
<param name="responseEntity">A <see cref="T:System.Byte" /> array that contains the response to send to the client.</param>
<param name="willBlock">
<see langword="true" /> to block execution while flushing the stream to the client; otherwise, <see langword="false" />.</param>
<summary>Returns the specified byte array to the client and releases the resources held by this <see cref="T:System.Net.HttpListenerResponse" /> instance.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
If you are sending body data with the response, you can use this method to send it as a <xref:System.Byte> array instead of writing the body data to the <xref:System.Net.HttpListenerResponse.OutputStream%2A> property and calling the <xref:System.Net.HttpListenerResponse.Close%2A> method.
This method closes the response stream and the <xref:System.Net.HttpListenerRequest> associated with the response.
If `false` is specified as the `willBlock`, the method returns immediately and the connection is closed asynchronously once the data is sent.
> [!NOTE]
> If closing asynchronously, it is not possible for the caller to determine when the data have been sent. In addition to that, disposing the <xref:System.Net.HttpListenerResponse>, <xref:System.Net.HttpListenerContext> or <xref:System.Net.HttpListener> may close the connection before all the data are sent.
## Examples
The following code example demonstrates calling this method.
:::code language="csharp" source="~/snippets/csharp/System.Net/HttpListener/Overview/test.cs" id="Snippet24":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Net_Listener_Basic/VB/test.vb" id="Snippet24":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="responseEntity" /> is <see langword="null" />.</exception>
<exception cref="T:System.ObjectDisposedException">This object is closed.</exception>
<altmember cref="T:System.Net.HttpListener" />
<altmember cref="T:System.Net.HttpListenerContext" />
<altmember cref="T:System.Net.HttpListenerRequest" />
</Docs>
</Member>
<Member MemberName="ContentEncoding">
<MemberSignature Language="C#" Value="public System.Text.Encoding? ContentEncoding { get; set; }" FrameworkAlternate="net-5.0;net-6.0;net-7.0;net-8.0;net-9.0" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Text.Encoding ContentEncoding" />
<MemberSignature Language="DocId" Value="P:System.Net.HttpListenerResponse.ContentEncoding" />
<MemberSignature Language="VB.NET" Value="Public Property ContentEncoding As Encoding" />
<MemberSignature Language="F#" Value="member this.ContentEncoding : System.Text.Encoding with get, set" Usage="System.Net.HttpListenerResponse.ContentEncoding" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Text::Encoding ^ ContentEncoding { System::Text::Encoding ^ get(); void set(System::Text::Encoding ^ value); };" />
<MemberSignature Language="C#" Value="public System.Text.Encoding ContentEncoding { get; set; }" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-2.0;netstandard-2.1" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Net.HttpListener</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.Nullable(2)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.Nullable(2)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="net-8.0;net-9.0">
<AttributeName Language="C#">[get: System.Runtime.CompilerServices.NullableContext(2)]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.CompilerServices.NullableContext(2)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="net-8.0;net-9.0">
<AttributeName Language="C#">[set: System.Runtime.CompilerServices.NullableContext(2)]</AttributeName>
<AttributeName Language="F#">[<set: System.Runtime.CompilerServices.NullableContext(2)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Text.Encoding</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the <see cref="T:System.Text.Encoding" /> for this response's <see cref="P:System.Net.HttpListenerResponse.OutputStream" />.</summary>
<value>An <see cref="T:System.Text.Encoding" /> object suitable for use with the data in the <see cref="P:System.Net.HttpListenerResponse.OutputStream" /> property, or <see langword="null" /> if no encoding is specified.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
An <xref:System.Text.Encoding> object can be used to convert byte sequences into character sets (code pages) and characters into byte sequences.
## Examples
The following code example demonstrates using this property.
:::code language="csharp" source="~/snippets/csharp/System.Net/AuthenticationSchemes/Overview/sample.cs" id="Snippet5":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLListener/vb/sample.vb" id="Snippet5":::
]]></format>
</remarks>
<altmember cref="T:System.Net.HttpListener" />
<altmember cref="T:System.Net.HttpListenerContext" />
<altmember cref="T:System.Net.HttpListenerRequest" />
</Docs>
</Member>
<Member MemberName="ContentLength64">
<MemberSignature Language="C#" Value="public long ContentLength64 { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance int64 ContentLength64" />
<MemberSignature Language="DocId" Value="P:System.Net.HttpListenerResponse.ContentLength64" />
<MemberSignature Language="VB.NET" Value="Public Property ContentLength64 As Long" />
<MemberSignature Language="F#" Value="member this.ContentLength64 : int64 with get, set" Usage="System.Net.HttpListenerResponse.ContentLength64" />
<MemberSignature Language="C++ CLI" Value="public:
 property long ContentLength64 { long get(); void set(long value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Net.HttpListener</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Int64</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the number of bytes in the body data included in the response.</summary>
<value>The value of the response's <see langword="Content-Length" /> header.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The `Content-Length` header expresses the length, in bytes, of the response's body data. When using a format that does not send the data chunked or raw, you must set the <xref:System.Net.HttpListenerResponse.ContentLength64%2A> property. If you do not, the <xref:System.Net.HttpListener> does not send the response data.
For a complete list of response headers, see the <xref:System.Net.HttpResponseHeader> enumeration.
## Examples
The following code example demonstrates setting the value of this property.
:::code language="csharp" source="~/snippets/csharp/System.Net/HttpListener/Overview/test.cs" id="Snippet2":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Net_Listener_Basic/VB/test.vb" id="Snippet2":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentOutOfRangeException">The value specified for a set operation is less than zero.</exception>
<exception cref="T:System.InvalidOperationException">The response is already being sent.</exception>
<exception cref="T:System.ObjectDisposedException">This object is closed.</exception>
<altmember cref="T:System.Net.HttpListener" />
<altmember cref="T:System.Net.HttpListenerContext" />
<altmember cref="T:System.Net.HttpListenerRequest" />
</Docs>
</Member>
<Member MemberName="ContentType">
<MemberSignature Language="C#" Value="public string? ContentType { get; set; }" FrameworkAlternate="net-5.0;net-6.0;net-7.0;net-8.0;net-9.0" />
<MemberSignature Language="ILAsm" Value=".property instance string ContentType" />
<MemberSignature Language="DocId" Value="P:System.Net.HttpListenerResponse.ContentType" />
<MemberSignature Language="VB.NET" Value="Public Property ContentType As String" />
<MemberSignature Language="F#" Value="member this.ContentType : string with get, set" Usage="System.Net.HttpListenerResponse.ContentType" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::String ^ ContentType { System::String ^ get(); void set(System::String ^ value); };" />
<MemberSignature Language="C#" Value="public string ContentType { get; set; }" FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;netcore-3.0;netcore-3.1;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;netstandard-2.0;netstandard-2.1" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Net.HttpListener</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="net-8.0;net-9.0">
<AttributeName Language="C#">[System.Runtime.CompilerServices.Nullable(2)]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.CompilerServices.Nullable(2)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="net-8.0;net-9.0">
<AttributeName Language="C#">[get: System.Runtime.CompilerServices.NullableContext(2)]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.CompilerServices.NullableContext(2)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="net-8.0;net-9.0">
<AttributeName Language="C#">[set: System.Runtime.CompilerServices.NullableContext(2)]</AttributeName>
<AttributeName Language="F#">[<set: System.Runtime.CompilerServices.NullableContext(2)>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the MIME type of the content returned.</summary>
<value>A <see cref="T:System.String" /> instance that contains the text of the response's <see langword="Content-Type" /> header.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When communicating with a Web browser, you should explicitly set this property when returning any content type other than `text/html`.
For a complete list of response headers, see the <xref:System.Net.HttpResponseHeader> enumeration.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The value specified for a set operation is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">The value specified for a set operation is an empty string ("").</exception>
<exception cref="T:System.ObjectDisposedException">This object is closed.</exception>
<altmember cref="T:System.Net.HttpListener" />
<altmember cref="T:System.Net.HttpListenerContext" />
<altmember cref="T:System.Net.HttpListenerRequest" />
</Docs>
</Member>
<Member MemberName="Cookies">
<MemberSignature Language="C#" Value="public System.Net.CookieCollection Cookies { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Net.CookieCollection Cookies" />
<MemberSignature Language="DocId" Value="P:System.Net.HttpListenerResponse.Cookies" />
<MemberSignature Language="VB.NET" Value="Public Property Cookies As CookieCollection" />
<MemberSignature Language="F#" Value="member this.Cookies : System.Net.CookieCollection with get, set" Usage="System.Net.HttpListenerResponse.Cookies" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Net::CookieCollection ^ Cookies { System::Net::CookieCollection ^ get(); void set(System::Net::CookieCollection ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Net.HttpListener</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<set: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Net.CookieCollection</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the collection of cookies returned with the response.</summary>
<value>A <see cref="T:System.Net.CookieCollection" /> that contains cookies to accompany the response. The collection is empty if no cookies have been added to the response.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
A cookie is name/value text data from a Web server that is stored on the local (client) computer. The following cookie formats are supported: Netscape, [RFC 2109](https://www.rfc-editor.org/info/rfc2109), and [RFC 2965](https://www.rfc-editor.org/info/rfc2965).
## Examples
The following code example checks a request for a cookie, and returns a new cookie with the response if the request did not have one.
:::code language="csharp" source="~/snippets/csharp/System.Net/HttpListener/Overview/test.cs" id="Snippet20":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Net_Listener_Basic/VB/test.vb" id="Snippet20":::
]]></format>
</remarks>
<altmember cref="T:System.Net.HttpListener" />
<altmember cref="T:System.Net.HttpListenerContext" />
<altmember cref="T:System.Net.HttpListenerRequest" />
</Docs>
</Member>
<Member MemberName="CopyFrom">
<MemberSignature Language="C#" Value="public void CopyFrom (System.Net.HttpListenerResponse templateResponse);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void CopyFrom(class System.Net.HttpListenerResponse templateResponse) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Net.HttpListenerResponse.CopyFrom(System.Net.HttpListenerResponse)" />
<MemberSignature Language="VB.NET" Value="Public Sub CopyFrom (templateResponse As HttpListenerResponse)" />
<MemberSignature Language="F#" Value="member this.CopyFrom : System.Net.HttpListenerResponse -> unit" Usage="httpListenerResponse.CopyFrom templateResponse" />
<MemberSignature Language="C++ CLI" Value="public:
 void CopyFrom(System::Net::HttpListenerResponse ^ templateResponse);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Net.HttpListener</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="templateResponse" Type="System.Net.HttpListenerResponse" />
</Parameters>
<Docs>
<param name="templateResponse">The <see cref="T:System.Net.HttpListenerResponse" /> instance to copy.</param>
<summary>Copies properties from the specified <see cref="T:System.Net.HttpListenerResponse" /> to this response.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
If you regularly change many properties from their default values to a fixed set of new values, it is convenient to use an <xref:System.Net.HttpListenerResponse> instance as a template. Customize the template response once and, instead of configuring each response separately, call the <xref:System.Net.HttpListenerResponse.CopyFrom%2A> method to configure a new response based on property values in the template response.
The following properties are copied from `templateResponse` to the current instance.
- <xref:System.Net.HttpListenerResponse.Headers%2A>
- <xref:System.Net.HttpListenerResponse.ContentLength64%2A>
- <xref:System.Net.HttpListenerResponse.StatusCode%2A>
- <xref:System.Net.HttpListenerResponse.StatusDescription%2A>
- <xref:System.Net.HttpListenerResponse.KeepAlive%2A>
- <xref:System.Net.HttpListenerResponse.ProtocolVersion%2A>
## Examples
The following code example demonstrates creating a response by copying a template response.
:::code language="csharp" source="~/snippets/csharp/System.Net/AuthenticationSchemes/Overview/sample.cs" id="Snippet5":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLListener/vb/sample.vb" id="Snippet5":::
]]></format>
</remarks>
<altmember cref="T:System.Net.HttpListener" />
<altmember cref="T:System.Net.HttpListenerContext" />
<altmember cref="T:System.Net.HttpListenerRequest" />
</Docs>
</Member>
<Member MemberName="Headers">
<MemberSignature Language="C#" Value="public System.Net.WebHeaderCollection Headers { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Net.WebHeaderCollection Headers" />
<MemberSignature Language="DocId" Value="P:System.Net.HttpListenerResponse.Headers" />
<MemberSignature Language="VB.NET" Value="Public Property Headers As WebHeaderCollection" />
<MemberSignature Language="F#" Value="member this.Headers : System.Net.WebHeaderCollection with get, set" Usage="System.Net.HttpListenerResponse.Headers" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Net::WebHeaderCollection ^ Headers { System::Net::WebHeaderCollection ^ get(); void set(System::Net::WebHeaderCollection ^ value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Net.HttpListener</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Net.WebHeaderCollection</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the collection of header name/value pairs returned by the server.</summary>
<value>A <see cref="T:System.Net.WebHeaderCollection" /> instance that contains all the explicitly set HTTP headers to be included in the response.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Response headers contain metadata information such as the date and time of the response, the identity of the responding server, and the MIME type of the data contained in the response body.
For a complete list of response headers, see the <xref:System.Net.HttpResponseHeader> enumeration.
> [!NOTE]
> If you attempt to set a Content-Length, Keep-Alive, Transfer-Encoding, or WWW-Authenticate header using the Headers property, an exception will be thrown. Use the <xref:System.Net.HttpListenerResponse.KeepAlive%2A> or <xref:System.Net.HttpListenerResponse.ContentLength64%2A> properties to set these headers. You cannot set the Transfer-Encoding or WWW-Authenticate headers manually.
## Examples
The following code example demonstrates displaying the headers in a <xref:System.Net.WebHeaderCollection>.
:::code language="csharp" source="~/snippets/csharp/System.Net/HttpListener/Overview/test.cs" id="Snippet23":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Net_Listener_Basic/VB/test.vb" id="Snippet23":::
]]></format>
</remarks>
<exception cref="T:System.InvalidOperationException">The <see cref="T:System.Net.WebHeaderCollection" /> instance specified for a set operation is not valid for a response.</exception>
<altmember cref="T:System.Net.HttpListener" />
<altmember cref="T:System.Net.HttpListenerContext" />
<altmember cref="T:System.Net.HttpListenerRequest" />
</Docs>
</Member>
<Member MemberName="KeepAlive">
<MemberSignature Language="C#" Value="public bool KeepAlive { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance bool KeepAlive" />
<MemberSignature Language="DocId" Value="P:System.Net.HttpListenerResponse.KeepAlive" />
<MemberSignature Language="VB.NET" Value="Public Property KeepAlive As Boolean" />
<MemberSignature Language="F#" Value="member this.KeepAlive : bool with get, set" Usage="System.Net.HttpListenerResponse.KeepAlive" />
<MemberSignature Language="C++ CLI" Value="public:
 property bool KeepAlive { bool get(); void set(bool value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Net.HttpListener</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets a value indicating whether the server requests a persistent connection.</summary>
<value>
<see langword="true" /> if the server requests a persistent connection; otherwise, <see langword="false" />. The default is <see langword="true" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
If an HTTP client and server expect to exchange data multiple times in a short period, a persistent connection speeds up their communications by allowing them to avoid the overhead required to open and close a TCP connection for each message. Persistent connections are in widespread use in communications between modern Web browsers and Web servers.
Persistent connections are described in detail in the HTTP/1.1 protocol specification (RFC 2616) available at the RTF Editor Web site ([https://www.rfc-editor.org/](https://www.rfc-editor.org/)).
## Examples
The following code example demonstrates setting the value of this property.
:::code language="csharp" source="~/snippets/csharp/System.Net/AuthenticationSchemes/Overview/sample.cs" id="Snippet7":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/NCLListener/vb/sample.vb" id="Snippet7":::
]]></format>
</remarks>
<exception cref="T:System.ObjectDisposedException">This object is closed.</exception>
<altmember cref="T:System.Net.HttpListener" />
<altmember cref="T:System.Net.HttpListenerContext" />
<altmember cref="T:System.Net.HttpListenerRequest" />
</Docs>
</Member>
<Member MemberName="OutputStream">
<MemberSignature Language="C#" Value="public System.IO.Stream OutputStream { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.IO.Stream OutputStream" />
<MemberSignature Language="DocId" Value="P:System.Net.HttpListenerResponse.OutputStream" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property OutputStream As Stream" />
<MemberSignature Language="F#" Value="member this.OutputStream : System.IO.Stream" Usage="System.Net.HttpListenerResponse.OutputStream" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::IO::Stream ^ OutputStream { System::IO::Stream ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>netstandard</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.Net.HttpListener</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.1.0</AssemblyVersion>
<AssemblyVersion>4.0.2.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>