dotnet / dotnet/aspnetcore

Avoid magic string in asp-page-handler

Open
#54,816 0 comments 1 reaction 0 assignees View on GitHub
area-mvc
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is your feature request related to a problem? Please describe the problem.

If a `PageModel` has multiple POST handlers, then one specify to the tag helper which handler to use.

For example, if the model has `OnPostAddAsync` and `OnPostRemoveAsync` then one must use
```html

```

But that requires the use of a magic string; it's easy to break and completely unprofessional.

So we do this instead:
```html

```

Although that works, our code is littered with these ugly hacks which lowers readability.

### Describe the solution you'd like

Please allow multiple handler definitions. One is already allowed to use `Add` and `AddAsync`, so please allow all the four combinations:
- `Add`
- `AddAsync`
- `OnPostAdd`
- `OnPostAddAsync`

Then we could use:
```html

```

### Additional context

Thank you!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.