在ASP.NET MVC中,如何更改操作参数并使它工作而不更改路由? [英] How to change action parameters and get it to work without changing routing in asp.net mvc?
本文介绍了在ASP.NET MVC中,如何更改操作参数并使它工作而不更改路由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的路线上,我有这样的东西:
In my route I have something like this:
controller/action/{id}
据我所知,这将调用具有参数id的任何操作,如下所示:
To my knowledge this means it will call any action with the parameter id like the following:
public ActionResult Detail(string id)
{
}
在不将特定路径注册到global.asax文件中的情况下,如何做以下工作:
What do I have to do to make the following work without registering the particular route in global.asax file:
public ActionResult Detail(string customerId)
{
}
推荐答案
具有类似于-controller / action / {customerId}的路由,或者只是将参数 customerId
重命名为 id
,然后以所需的特定方式使用它。
have a route like - controller/action/{customerId} or just rename the parameter customerId
to id
and then use it the particular way you want.
这篇关于在ASP.NET MVC中,如何更改操作参数并使它工作而不更改路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文