# Compute Engine v1 API - Class PathRule (3.28.0)

3.28.0 (latest) 3.27.0 3.26.0 3.25.0 3.24.0 3.23.0 3.22.0 3.21.0 3.20.0 3.19.0 3.18.0 3.17.0 3.16.0 3.15.0 3.14.0 3.13.0 3.12.0 3.11.0 3.10.0 3.9.0 3.8.0 3.7.0 3.6.0 3.5.0 3.4.0 3.3.0 3.2.0 3.1.0 3.0.0 2.17.0 2.16.0 2.15.0 2.14.0 2.13.0 2.12.0 2.11.0 2.10.0 2.9.0 2.8.0 2.7.0 2.6.0 2.5.0 2.4.0 2.3.0 2.2.0 2.1.0 2.0.0 1.4.0 1.3.0 1.2.0 1.1.0 1.0.0

    public sealed class PathRule : IMessage<PathRule>, IEquatable<PathRule>, IDeepCloneable<PathRule>, IBufferMessage, IMessage

Reference documentation and code samples for the Compute Engine v1 API class PathRule.

A path-matching rule for a URL. If matched, will use the specifiedBackendService to handle the traffic arriving at this URL.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> PathRule

## Implements

[IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage-1.html)[PathRule](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Compute.V1/latest/Google.Cloud.Compute.V1.PathRule), [IEquatable](https://learn.microsoft.com/dotnet/api/system.iequatable-1)[PathRule](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Compute.V1/latest/Google.Cloud.Compute.V1.PathRule), [IDeepCloneable](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IDeepCloneable-1.html)[PathRule](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Compute.V1/latest/Google.Cloud.Compute.V1.PathRule), [IBufferMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IBufferMessage.html), [IMessage](https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.IMessage.html)

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Cloud.Compute.V1](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Compute.V1/latest/Google.Cloud.Compute.V1)

## Assembly

Google.Cloud.Compute.V1.dll

## Constructors

### PathRule()

    public PathRule()

### PathRule(PathRule)

    public PathRule(PathRule other)

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `other` | `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Compute.V1/latest/Google.Cloud.Compute.V1.PathRule` |

## Properties

### CustomErrorResponsePolicy

    public CustomErrorResponsePolicy CustomErrorResponsePolicy { get; set; }

customErrorResponsePolicy specifies how the Load
Balancer returns error responses when BackendServiceorBackendBucket responds with an error.

If a policy for an
error code is not configured for the PathRule, a policy for
the error code configured inpathMatcher.defaultCustomErrorResponsePolicy is applied. If
one is not specified inpathMatcher.defaultCustomErrorResponsePolicy, the policy
configured in UrlMap.defaultCustomErrorResponsePolicy takes
effect.

For example, consider a UrlMap with the following configuration:

     - UrlMap.defaultCustomErrorResponsePolicy are configured
     with policies for 5xx and 4xx errors
     - A PathRule for /coming_soon/ is configured for the error
     code 404.

If the request is for www.myotherdomain.com and a404 is encountered, the policy underUrlMap.defaultCustomErrorResponsePolicy takes effect. If a404 response is encountered for the requestwww.example.com/current_events/, the pathMatcher's policy
takes effect. If however, the request forwww.example.com/coming_soon/ encounters a 404,
the policy in PathRule.customErrorResponsePolicy takes
effect. If any of the requests in this example encounter a 500
error code, the policy atUrlMap.defaultCustomErrorResponsePolicy takes effect.

customErrorResponsePolicy is supported only for
global external Application Load Balancers.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Compute.V1/latest/Google.Cloud.Compute.V1.CustomErrorResponsePolicy` |   |

### HasService

    public bool HasService { get; }

Gets whether the "service" field is set

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.boolean` |   |

### Paths

    public RepeatedField<string> Paths { get; }

The list of path patterns to match. Each must start with /
and the only place a \* is allowed is at the end following
a /. The string fed to the path matcher does not include
any text after the first ? or #, and
those chars are not allowed here.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://cloud.google.com/dotnet/docs/reference/Google.Protobuf/latest/Google.Protobuf.Collections.RepeatedField-1.htmlhttps://learn.microsoft.com/dotnet/api/system.string` |   |

### RouteAction

    public HttpRouteAction RouteAction { get; set; }

In response to a matching path, the load balancer
performs advanced routing actions, such as URL rewrites and header
transformations, before forwarding the request to the selected
backend.

Only one of urlRedirect, service orrouteAction.weightedBackendService can be set.

URL maps for classic Application Load Balancers only support
the urlRewrite action within a path rule'srouteAction.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Compute.V1/latest/Google.Cloud.Compute.V1.HttpRouteAction` |   |

### Service

    public string Service { get; set; }

The full or partial URL of the backend service resource to which traffic
is directed if this rule is matched. If routeAction is
also specified, advanced routing actions, such as URL rewrites,
take effect before sending the request to the backend.

Only one of urlRedirect, service orrouteAction.weightedBackendService can be set.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

### UrlRedirect

    public HttpRedirectAction UrlRedirect { get; set; }

When a path pattern is matched, the request is redirected to a URL
specified by urlRedirect.

Only one of urlRedirect, service orrouteAction.weightedBackendService can be set.

Not supported when the URL map is bound to a target gRPC proxy.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Compute.V1/latest/Google.Cloud.Compute.V1.HttpRedirectAction` |   |