AspNetCore.Docs/aspnetcore/diagnostics/asp0018.md

39 lines
891 B
Markdown
Raw Normal View History

---
title: "ASP0018: Unused route parameter"
description: "Learn about analysis rule ASP0018: Unused route parameter"
author: tdykstra
monikerRange: '>= aspnetcore-8.0'
ms.author: tdykstra
ms.date: 11/22/2022
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
A route parameter is specified but not used. In the example below, the `name` parameter is defined in the route but not in the route handler.
```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.
## When to suppress warnings
Do not suppress a warning from this rule.