gpt4 book ai didi

c# - 如何使用 MVC 在同一个 Controller 中复制一个 Action

转载 作者:行者123 更新时间:2023-11-30 13:19:41 25 4
gpt4 key购买 nike

我在一个 Controller 中有 2 个 Action

public ActionResult DoSomething()
{
...
}

public ActionResult SoSomethingAgain()
{
...
}

我希望两个请求都执行相同的操作。

也许是别名....

[ie. SoSomethingAgain]
public ActionResult DoSomething()
{
...
}

什么是正确的方法?

最佳答案

如果我没看错你可以这样做:

public ActionResult DoSomething()
{
...
}

public ActionResult SoSomethingAgain()
{
return DoSomething();
}

关于c# - 如何使用 MVC 在同一个 Controller 中复制一个 Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17200100/

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