---
sidebar_position: 7
title: Redirection
---

## Perform a redirect

Now that you can add an item, it would be interesting to redirect the user to the list when adding it.

Open the `Pages/Add.razor.cs` file and add the highlighted lines:

```csharp title="Pages/Add.razor.cs"
public partial class Add
{
	...

// highlight-start
	[Inject]
	public NavigationManager NavigationManager { get; set; }
// highlight-end

	...
	
	private async void HandleValidSubmit()
	{
		...

		// Save the data
		await LocalStorage.SetItemAsync("data", currentData);

// highlight-next-line
        NavigationManager.NavigateTo("list");
	}
}
```

## Concept: URI and navigation state helpers

Use `NavigationManager` to manage URIs and navigation in C# code. `NavigationManager` provides the event and methods shown in the following table.

| Membre | Description |
| ---- | ---- |
| Uri | Gets the current absolute URI. |
| BaseUri | Gets the base URI (with a trailing slash) that can be prepended to relative URI paths to produce an absolute URI. Typically, `BaseUri` corresponds to the `href` attribute on the document's `<base>` element in `wwwroot/index.html` (Blazor WebAssembly) or `Pages/_Layout.cshtml` (Blazor Server). |
| NavigateTo | Navigates to the specified URI. If `forceLoad` is `true`: <ul><li>Client-side routing is bypassed.</li><li>The browser is forced to load the new page from the server, whether or not the URI is normally handled by the client-side router.</li></ul>If `replace` is `true`, the current URI in the browser history is replaced instead of pushing a new URI onto the history stack. |
| LocationChanged | An event that fires when the navigation location has changed.  |
| ToAbsoluteUri | Converts a relative URI into an absolute URI. |
| ToBaseRelativePath | 	Given a base URI (for example, a URI previously returned by BaseUri), converts an absolute URI into a URI relative to the base URI prefix. |
| GetUriWithQueryParameter | Returns a URI constructed by updating NavigationManager.Uri with a single parameter added, updated, or removed. |
