gpt4 book ai didi

asp.net-mvc - 什么对象属性包含在 ControllerBase 中使用的路由名称

转载 作者:行者123 更新时间:2023-12-02 02:35:21 26 4
gpt4 key购买 nike

如何找到在 ControllerBase 内部使用的路由名称?

例如,我有这样一条路线:

routes.MapRoute("Search", "{controller}.mvc/{action}/{criterion}", new { controller = "", action = "", criterion = "" });

...在我的 ControllerBase 中,我需要包含“搜索”的 Object.Property 或 ControllerBase 当前使用的路由名称(如果不搜索的话)。

谢谢。

-杰西·豪尔

最佳答案

这个问题已经以各种形式多次出现。简短的回答是你不能——路由名称没有存储在路由数据中的任何地方。

为此提出了各种解决方法。 See this answer对于一种实现路由名称跟踪的一些代码。周围还有其他人。

关于asp.net-mvc - 什么对象属性包含在 ControllerBase 中使用的路由名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2065878/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com