asp.net - Transformer 约定 ASP.NET Slugify 参数
问题描述
我在控制器中有这个标签:[HttpGet("CompaniesNotConfigured")] 我希望这个方法的路径使用 SlugifyTransformerConvention,换句话说,我希望这个路径是这样的:
https://localhost:49229/company-configuration/companies-not-configured
然后,我使用了这种方法:
public class SlugifyTransformerConvention : IOutboundParameterTransformer
{
public string TransformOutbound(object value)
{
if (value == null) { return null; }
return Regex.Replace(value.ToString(),
"([a-z])([A-Z])",
"$1-$2",
RegexOptions.CultureInvariant,
TimeSpan.FromMilliseconds(100)).ToLowerInvariant();
}
}
但它不起作用。那么,我该怎么做呢?