HttpResponse.StatusCode Properti

Definisi

Mendapatkan atau mengatur kode status HTTP dari output yang dikembalikan ke klien.

public:
 property int StatusCode { int get(); void set(int value); };
public int StatusCode { get; set; }
member this.StatusCode : int with get, set
Public Property StatusCode As Integer

Nilai Properti

Bilangan bulat yang mewakili status output HTTP yang dikembalikan ke klien. Nilai defaultnya adalah 200 (OK). Untuk daftar kode status yang valid, lihat Kode Status HTTP.

Pengecualian

StatusCode diatur setelah header HTTP dikirim.

Contoh

Contoh berikut memeriksa kode status aliran output. Jika kode status tidak sama dengan 200, kode tambahan dijalankan.

protected void Page_Load(object sender, EventArgs e)
{
    // Show success or failure of page load.
    if (Response.StatusCode != 200)
    {
        Response.Write("There was a problem accessing the web resource" +
            "<br />" + Response.StatusDescription);
    }
}

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

    ' Show success or failure of page load.
    If Response.StatusCode <> 200 Then
        Response.Write("There was a problem accessing the web resource." & _
            "<br />" & Response.StatusDescription)
    End If

End Sub

Berlaku untuk

Lihat juga