Table of Contents

Property ResponseCode

Namespace
DotNetBrowser.Navigation.Events
Assembly
DotNetBrowser.dll

ResponseCode

The HTTP status code returned by the server in response to the navigation request.

public int ResponseCode { get; }

Property Value

int

The numeric HTTP status code (e.g., 200 for OK, 404 for Not Found) returned in response to the navigation request. If the navigation does not yield a response with headers, the value will be 0.

Remarks

This property is populated when the navigation results in a response that includes valid response headers.

This includes the following cases:

  • The server returns HTTP(S) response headers with a status code (e.g., 200, 404).
  • Chromium creates a synthetic response header for a well-formed data: URL (for example, data:,Hello). In this case, the status code is typically 200 (OK).
  • Chromium creates a response header for a valid file: URL if the file exists, also typically with status code 200 (OK).
If the navigation does not result in a response with headers, this field is set to 0.

This includes the following cases:

  • The navigation failed at the network level (e.g., DNS failure, timeout, connection refused, offline).
  • The navigation failed due to invalid scheme target URLs:
    • Malformed data: URLs (e.g., missing comma or invalid format). No synthetic header is created.
    • file: URL for a file that does not exist. No synthetic header is created.
  • The target URL uses a scheme that does not involve an HTTP(S) response and therefore does not produce response headers, including:
    • about: (e.g., about:blank)
    • chrome:, chrome-extension: (internal browser/extension pages)
  • The navigation was performed within the same document:
    • Fragment navigations (e.g., navigating to #anchor)
    • History API navigations (e.g., pushState, replaceState)

Note: A value of 0 does not mean the server responded with HTTP status code 0. It means that the HTTP status code could not be determined because no HTTP-level response occurred or no synthetic response was generated for the navigation.