Advertisement
Guest User

Untitled

a guest
May 16th, 2022
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. public static class MyTagHelpers
  2. {
  3. public static string Prepare(this IUrlHelper helper, string value)
  4. {
  5. if (helper == null)
  6. throw new ArgumentNullException(nameof(helper));
  7.  
  8. if (value.EndsWith("Controller"))
  9. return value[..^10];
  10. if (value.EndsWith("Async"))
  11. return value[..^5];
  12. return value;
  13. }
  14. }
  15.  
  16.  
  17. <form method="post"
  18. asp-controller="@Url.Prepare(nameof(FooController))"
  19. asp-action="@Url.Prepare(nameof(FooController.BarsAsync))"></form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement