# HttpResponse

Namespace: **Wisej.Core**

Assembly: **Wisej.Framework** (3.0.0.0)

Encapsulates HTTP-response information from an ASP.NET operation.

{% tabs %}
{% tab title="C#" %}

```csharp
public class HttpResponse
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class HttpResponse
```

{% endtab %}
{% endtabs %}

## Properties

### ![](https://2647619304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHOivImCoV8KSJbQyp6QI%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)ContentType

[String](https://docs.microsoft.com/en-us/dotnet/api/system.string): Returns or set the HTTP MIME type of the output stream.

### ![](https://2647619304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHOivImCoV8KSJbQyp6QI%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)Context

[HttpContext](https://docs.wisej.com/api/v3.0/wisej.core/general/wisej.core.httpcontext): Returns the current [HttpContext](https://docs.wisej.com/api/v3.0/wisej.core/general/wisej.core.httpcontext).

### ![](https://2647619304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHOivImCoV8KSJbQyp6QI%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)OutputStream

[Stream](https://docs.microsoft.com/en-us/dotnet/api/system.io.stream): Enables binary output to the outgoing HTTP content body.

### ![](https://2647619304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHOivImCoV8KSJbQyp6QI%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)StatusCode

[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32): Returns or sets the HTTP status code returned to the client.

### ![](https://2647619304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHOivImCoV8KSJbQyp6QI%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)StatusDescription

[String](https://docs.microsoft.com/en-us/dotnet/api/system.string): Returns or sets the HTTP status string to return to the client.

## Methods

### ![](https://2647619304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHOivImCoV8KSJbQyp6QI%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)AppendHeader(name, value)

Adds the HTTP header to the response.

| Parameter | Type                                                                | Description               |
| --------- | ------------------------------------------------------------------- | ------------------------- |
| **name**  | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | Name of the HTTP header.  |
| **value** | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | Value of the HTTP header. |

### ![](https://2647619304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHOivImCoV8KSJbQyp6QI%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)BinaryWrite(buffer)

Writes an array of bytes to the HTTP output stream.

| Parameter  | Type                                                                | Description                              |
| ---------- | ------------------------------------------------------------------- | ---------------------------------------- |
| **buffer** | [Byte\[\]](https://docs.microsoft.com/en-us/dotnet/api/system.byte) | The bytes to write to the output stream. |

### ![](https://2647619304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHOivImCoV8KSJbQyp6QI%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)BinaryWrite(buffer, index, count)

Writes an array of bytes to the HTTP output stream.

| Parameter  | Type                                                                | Description                                          |
| ---------- | ------------------------------------------------------------------- | ---------------------------------------------------- |
| **buffer** | [Byte\[\]](https://docs.microsoft.com/en-us/dotnet/api/system.byte) | The bytes to write to the output stream.             |
| **index**  | [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)   | The position in the byte array where writing starts. |
| **count**  | [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)   | The number of bytes to write, beginning at index.    |

### ![](https://2647619304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHOivImCoV8KSJbQyp6QI%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)Flush()

Sends all currently buffered output to the client.

**Throws:**

* [HttpException](https://docs.microsoft.com/en-us/dotnet/api/system.web.httpexception) The cache is flushed after the response has been sent.

### ![](https://2647619304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHOivImCoV8KSJbQyp6QI%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)Redirect(location, permanent)

Returns a redirect response (HTTP 301 or HTTP 302) to the client.

| Parameter     | Type                                                                  | Description                                                                                                                       |
| ------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| **location**  | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)   | The URL to redirect the client to. This must be properly encoded for use in HTTP headers where only ASCII characters are allowed. |
| **permanent** | [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean) | True if the redirect is permanent (301), otherwise false (302).                                                                   |

### ![](https://2647619304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHOivImCoV8KSJbQyp6QI%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)TransmitFile(filePath)

Writes the specified *filePath* to the current HTTP response stream without buffering it in memory.

| Parameter    | Type                                                                | Description                                        |
| ------------ | ------------------------------------------------------------------- | -------------------------------------------------- |
| **filePath** | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The path to the file to writ to the output stream. |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentnullexception) The filename parameter is null.

### ![](https://2647619304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHOivImCoV8KSJbQyp6QI%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)TransmitFile(filePath, offset, length)

Writes the specified part of a file directly to an HTTP response output stream without buffering it in memory.

| Parameter    | Type                                                                | Description                                                    |
| ------------ | ------------------------------------------------------------------- | -------------------------------------------------------------- |
| **filePath** | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The name of the file to write to the HTTP output.              |
| **offset**   | [Int64](https://docs.microsoft.com/en-us/dotnet/api/system.int64)   | The position in the file to begin to write to the HTTP output. |
| **length**   | [Int64](https://docs.microsoft.com/en-us/dotnet/api/system.int64)   | The number of bytes to be transmitted.                         |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentnullexception) The filename parameter is null.
* [PlatformNotSupportedException](https://docs.microsoft.com/en-us/dotnet/api/system.platformnotsupportedexception) The out-of-process worker request is not supported.- or -The response is not using an [HttpWriter](https://docs.microsoft.com/en-us/dotnet/api/system.web.httpwriter) object.
* [ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception) The offset parameter is less than zero or greater than the file size.- or -The length parameter is less than -1 or greater than the value of the offset parameter plus the file size.

### ![](https://2647619304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHOivImCoV8KSJbQyp6QI%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)TransmitImage(image, format)

Writes an image to the HTTP response stream.

| Parameter  | Type                                                                                          | Description                                                                                                                   |
| ---------- | --------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| **image**  | [Image](https://docs.microsoft.com/en-us/dotnet/api/system.drawing.image)                     | The [Image](https://docs.microsoft.com/en-us/dotnet/api/system.drawing.image) to send.                                        |
| **format** | [ImageFormat](https://docs.microsoft.com/en-us/dotnet/api/system.drawing.imaging.imageformat) | [ImageFormat](https://docs.microsoft.com/en-us/dotnet/api/system.drawing.imaging.imageformat) to use when encoding the image. |

**Throws:**

* [NullReferenceException](https://docs.microsoft.com/en-us/dotnet/api/system.nullreferenceexception) *image* is null.

### ![](https://2647619304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHOivImCoV8KSJbQyp6QI%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)TransmitStream(stream)

Copies a stream to the HTTP response stream.

| Parameter  | Type                                                                   | Description                                                                                          |
| ---------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| **stream** | [Stream](https://docs.microsoft.com/en-us/dotnet/api/system.io.stream) | A [Stream](https://docs.microsoft.com/en-us/dotnet/api/system.io.stream) to copy to the HTTP output. |

### ![](https://2647619304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHOivImCoV8KSJbQyp6QI%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)Write(value)

Writes a string to the current HTTP response string.

| Parameter | Type                                                                | Description                                 |
| --------- | ------------------------------------------------------------------- | ------------------------------------------- |
| **value** | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The string to write to the response stream. |

### ![](https://2647619304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHOivImCoV8KSJbQyp6QI%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media)Write(obj)

Writes an object to the HTTP response stream.

| Parameter | Type                                                                | Description          |
| --------- | ------------------------------------------------------------------- | -------------------- |
| **obj**   | [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) | The object to write. |
