Note: Since version 0.5.0, only VS2022 and the .NET 6 SDK are supported. you should still be able to build .NET 5/.NET Core 3.1 projects as long as you're using the .NET 6 SDK/VS2022 to build those projects.
UrlActionGenerator is a C# Source Generator for ASP.NET Core apps that create strongly typed extension methods for the generation of URL's in ASP.NET Core projects.
So instead of writing this by using magical strings:
<a asp-controller="Home" asp-action="Index" asp-route-param="4">Link</a>
You can write the following with the advantages of autocomplete and strong typing:
<a href="@Url.Actions().Home.Index(param: 4)">Link</a>
To start using this package, simply add the UrlActionGenerator
package to
your ASP.NET Core project by using the IDE tooling or running the below
command:
dotnet add package UrlActionGenerator
Once the package is added, extension methods are automatically added to the
IUrlHelper
interface based on the following template:
For MVC:
IUrlHelper.Actions().[ControllerName].[ActionName](...parameters)
IUrlHelper.[AreaName]Actions().[ControllerName].[ActionName](...parameters)
For Razor Pages:
IUrlHelper.Pages().[Folder].[Page](...parameters)
IUrlHelper.[AreaName]Pages().[Folder].[Page](...parameters)
For more examples check out the wiki for MVC examples or Razor Pages examples.
Interested in contributing? check out the technical details.