# Referrer

This part contains tools for working with HTTP referrer and other related things. Typical use-case of such tools is, for example, specifying of redirect back to entity's details form from edit form is needed after pressing "Ok" button or "Cancel" button.

## Controller extensions

| Method name        | Return type      | Description                                                                                                                                                                                                                                                                                                                   |
| ------------------ | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| RedirectToReferrer | `RedirectResult` | Creates `RedirectResult` object specifying redirect to url depending on presence `__Referrer` key (specified in `ReferrerConstants.Key`) in `HttpRequest.Form`. In case of existing of such key the corresponding url from `From` value will be used to redirect to. In other case the provided `url` parameter will be used. |

## HttpRequest extensions

| Method name | Return type | Description                                                                                                                                                  |
| ----------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| GetReferrer | `string`    | Gets a string containing url gotten from `HttpRequest.Form` with `__Referrer` key. If there are no such key then the specified url will be returned instead. |

## ReferrerTagHelper

An `TagHelper` implementation adding referrer link to page. It could be helpful when, for example, redirect back to entity's details form from edit form is needed after pressing "Ok" button or "Cancel" button.

```html
<a asp-referrer="@referrerAddress" class="btn btn-link btn-cancel">Cancel</a>
```

This will be (depending on context and app structure) rendered into something like:

```html
<a class="btn btn-link btn-cancel" href="/admin/users/7">Cancel</a>
<input name="__Referrer" type="hidden" value="/admin/users/7"/>
```


---

# 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.structr.dev/presentation/aspnetcore/referrer.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.
