Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在查看一些页面,我注意到默认情况下,控制器/动作/ID 的路由中的 ID 是整数而不是字符串。
我怎样才能改变它,使它成为一个字符串?
纯粹通过创建这样的动作:
Public Function MyAction(ByVal id as String) as ActionResult
该框架会MyController/MyAction/SomeId为您转换 url。通常它会将最后一部分转换为整数,因为这就是您的方法的定义方式,没有什么可以阻止您说它是一个字符串,因此不需要转换。
MyController/MyAction/SomeId