# HttpResponse

Namespace: **Wisej.Core**

Assembly: **Wisej.Framework** (4.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

### ![](/files/hsR4ok3152WyAf8J2C1u) ContentType

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

### ![](/files/hsR4ok3152WyAf8J2C1u) Context

[HttpContext](/api/wisej.core/general/wisej.core.httpcontext.md): Returns the current [HttpContext](/api/wisej.core/general/wisej.core.httpcontext.md).

### ![](/files/hsR4ok3152WyAf8J2C1u) OutputStream

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

### ![](/files/hsR4ok3152WyAf8J2C1u) StatusCode

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

### ![](/files/hsR4ok3152WyAf8J2C1u) StatusDescription

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

## Methods

### ![](/files/hsR4ok3152WyAf8J2C1u) AppendHeader(name, value)

Adds the HTTP header to the response.

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

### ![](/files/hsR4ok3152WyAf8J2C1u) BinaryWrite(buffer)

Writes an array of bytes to the HTTP output stream.

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

### ![](/files/hsR4ok3152WyAf8J2C1u) BinaryWrite(buffer, index, count)

Writes an array of bytes to the HTTP output stream.

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

### ![](/files/hsR4ok3152WyAf8J2C1u) Flush()

Sends all currently buffered output to the client.

**Throws:**

* [HttpException](https://docs.microsoft.com/dotnet/api/system.web.httpexception) An I/O error occurs.

### ![](/files/hsR4ok3152WyAf8J2C1u) Redirect(location, permanent)

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

| Parameter     | Type                                                            | Description                                                                                                                       |
| ------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| **location**  | [String](https://docs.microsoft.com/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/dotnet/api/system.boolean) | True if the redirect is permanent (301), otherwise false (302).                                                                   |

### ![](/files/hsR4ok3152WyAf8J2C1u) 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/dotnet/api/system.string) | The path to the file to writ to the output stream. |

**Throws:**

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

### ![](/files/hsR4ok3152WyAf8J2C1u) 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/dotnet/api/system.string) | The name of the file to write to the HTTP output.              |
| **offset**   | [Int64](https://docs.microsoft.com/dotnet/api/system.int64)   | The position in the file to begin to write to the HTTP output. |
| **length**   | [Int64](https://docs.microsoft.com/dotnet/api/system.int64)   | The number of bytes to be transmitted.                         |

**Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception) The filename parameter is null.
* [PlatformNotSupportedException](https://docs.microsoft.com/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/dotnet/api/system.web.httpwriter) object.
* [ArgumentException](https://docs.microsoft.com/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.

### ![](/files/hsR4ok3152WyAf8J2C1u) TransmitImage(image, format)

Writes an image to the HTTP response stream.

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

**Throws:**

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

### ![](/files/hsR4ok3152WyAf8J2C1u) TransmitStream(stream)

Copies a stream to the HTTP response stream.

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

### ![](/files/hsR4ok3152WyAf8J2C1u) Write(value)

Writes a string to the current HTTP response string.

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

### ![](/files/hsR4ok3152WyAf8J2C1u) Write(obj)

Writes an object to the HTTP response stream.

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

### ![](/files/hsR4ok3152WyAf8J2C1u) WriteFile(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/dotnet/api/system.string) | The path to the file to writ to the output stream. |

This method is an alias of [TransmitFile](#transmitfile-filepath). **Throws:**

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

### ![](/files/hsR4ok3152WyAf8J2C1u) WriteFile(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/dotnet/api/system.string) | The name of the file to write to the HTTP output.              |
| **offset**   | [Int64](https://docs.microsoft.com/dotnet/api/system.int64)   | The position in the file to begin to write to the HTTP output. |
| **length**   | [Int64](https://docs.microsoft.com/dotnet/api/system.int64)   | The number of bytes to be transmitted.                         |

This method is an alias of [TransmitFile](#transmitfile-filepath). **Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception) The filename parameter is null.
* [ArgumentException](https://docs.microsoft.com/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.

### ![](/files/hsR4ok3152WyAf8J2C1u) WriteImage(image, format)

Writes an image to the HTTP response stream.

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

This method is an alias of [TransmitImage](#transmitimage-image-format). **Throws:**

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

### ![](/files/hsR4ok3152WyAf8J2C1u) WriteStream(stream)

Copies a stream to the HTTP response stream.

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

This method is an alias of [TransmitStream](#transmitstream-stream). **Throws:**

* [ArgumentNullException](https://docs.microsoft.com/dotnet/api/system.argumentnullexception) *stream* is null.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/api/wisej.core/general/wisej.core.httpresponse.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
