# Attach an HTTP Request to an Existing Long-Running Transaction

When you are building a multi-page application, it might be useful to create an object in a transaction without committing it.

If you want to provide the user with a URL to an uncommitted object, you will need to attach the view-model of the request handler to the existing long-running transaction.

The following button handler creates a `Person` object and redirects to its page, without committing the object:

```csharp
public void Handle(Input.CreatePerson action)
{
    var person = new Person()
    {
        FirstName = "Uncommitted Guy"
    };

    RedirectUrl = "/people/persons/" + person.GetObjectID();
}
```

When the request handler for `"/people/persons/{?}"` catches the request after the redirection, it needs to search for the object by its ID in the existing long-running transaction:

```csharp
Handle.GET("/people/persons/{?}", (string id) =>
{
    MasterPage master = GetMasterPageFromSession();

    Action runPartialInScope = () =>
    {
        master.CurrentPage = Self.GET("/people/partials/persons/" + id);
    };

    if (master.CurrentPage.Transaction != null)
    {
        // Attach to a long running transaction of the existing CurrentPage
        master.CurrentPage.Transaction.Scope(runPartialInScope);
    }
    else
    {
        // If there was no existing CurrentPage, create a new transaction
        Db.Scope(runPartialInScope);
    }

    return master;
});
```

### Read more

[Guide: Long-running transactions](/2.3.1/guides/transactions/long-running-transactions.md)


---

# 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.starcounter.io/2.3.1/cookbook/attach-a-request-to-long-running-transactions.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.
