Skip to content

Strong typed tag helpers #45

Open
Open
@artiomchi

Description

@artiomchi

The tag helpers are working as expected and the mvc-action currently supports both synchronous and async actions. The issue is that these two types of actions have a different return type (IActionResult vs Task<IActionResult>)

In the tag helper code I've set the type of that attribute as object to allow both types of methods to be accepted, and am type checking when generating the url, but that doesn't seem ideal.

I've added additional "fake" attributes with the same name, which gives me the benefit of showing the other accepted action result types in intellisense, which is my current workaround.
image

Options that I came up with so far are:

  1. Leave it as is. The value type of the attribute is object, but it accepts all actions in a consistent way, and the intellisense provides users with hints on data types
  2. Generate separate attributes for synchronous and async actions.
    For example mvc-action and mvc-action-async
  3. Only support IActionResult in the tag helpers. For async actions, users will have to invoke .Result
<a mvc-action="MVC.Home.Index().Result">Async Index</a>

I'm interested to know what others thing would work best

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions