Posted by Anuraj on Tuesday, January 22, 2019 Reading time :1 minute
This post is about LinkGenerator in ASP.NET Core. Link Generator Service is a new service introduced in ASP.NET Core 2.2, which helps you to generate URLs. This new service can be used from middleware, and does not require an HttpContext.
You can use it in controller like this.
And you can use similar way in middleware as well. Unlike UriHelper, in LinkGenerator you can generate a link by just supplying the action and route values. You can specify controller name if not the current controller. For right now the set of things you can link to is limited to MVC actions, but this will expand in 3.0.
Happy Programming :)
What do you think? I would like to hear your thoughts, suggestions, and questions in the comments section below.