With conventional routing, you can customize the URL that is generated by an Anchor Tag Helper by implementing IRouter.GetVirtualPath
. GetVirtualPath isn't called when using attribute routing, however. Is there an equivalent way to customize the URL for an anchor that links to an action with attribute routing?
The setup code for conventional routing looks like this:
app.UseMvc(config => {
config.Routes.Add(new MyRouter());
// ... more routes ...
});
class MyRouter : IRouter
{
public VirtualPathData GetVirtualPath(VirtualPathContext context)
{
// ... customize URL here ...
}
}
An example of customizing the URL is to add a query parameter containing a simulated sub-domain.