2022-11-29 05:04:26 +08:00
---
title: "ASP0018: Unused route parameter"
description: "Learn about analysis rule ASP0018: Unused route parameter"
author: tdykstra
monikerRange: '>= aspnetcore-8.0'
ms.author: tdykstra
2024-04-04 01:48:26 +08:00
ms.date: 4/1/2024
2022-11-29 05:04:26 +08:00
uid: diagnostics/asp0018
---
# ASP0018: Unused route parameter
| | Value |
|-|-|
| **Rule ID** |ASP0018|
| **Category** |Usage|
| **Fix is breaking or non-breaking** |Non-breaking|
## Cause
A route parameter is specified but not used.
## Rule description
2023-12-01 07:32:11 +08:00
A route parameter is specified but not used. In the example below, the `id` parameter is defined in the route but not in the route handler.
2022-11-29 05:04:26 +08:00
```csharp
var app = WebApplication.Create();
app.MapGet("/{id}", () => ...);
```
## How to fix violations
To fix a violation of this rule, remove the route parameter or add code that uses the parameter.
2023-12-01 07:32:11 +08:00
```csharp
var app = WebApplication.Create();
2024-06-20 23:39:56 +08:00
app.MapGet("/{id}", (string id) => ...);
2023-12-01 07:32:11 +08:00
```
2022-11-29 05:04:26 +08:00
## When to suppress warnings
2024-04-04 01:48:26 +08:00
In general, do ** *not*** suppress a warning from this rule without validating the route parameter is used. Currently properties within the bound model for [FromRoute ](xref:Microsoft.AspNetCore.Mvc.FromRouteAttribute ) attributes may not be analyzed. For more information, see [GitHub issue `#54212` ](https://github.com/dotnet/aspnetcore/issues/54212 ).