有没有办法从我的自定义插件扩展GenericPathRoute.cs GetRouteData(...)中支持的实体,以便我可以为自定义实体添加通用URL支持?
//process URL
switch (urlRecord.EntityName.ToLowerInvariant())
{
case "product":
{
data.Values["controller"] = "Catalog";
data.Values["action"] = "Product";
data.Values["productid"] = urlRecord.EntityId;
data.Values["SeName"] = urlRecord.Slug;
}
break;
...
case "MyCustomEntity":
答案 0 :(得分:1)
可以试试这个:
<i>
public class CmsCustomUrlRecordEntityNameRequested : IConsumer<CustomUrlRecordEntityNameRequested>
{
void HandleEvent(CustomUrlRecordEntityNameRequested eventMessage)
{
eventMessage.RouteData.Values["controller"] = "Topic";
eventMessage.RouteData.Values["action"] = "TopicDetails";
eventMessage.RouteData.Values["topicId"] = urlRecord.EntityId;
eventMessage.RouteData.Values["SeName"] = urlRecord.Slug;
}
}
</i>