gpt4 book ai didi

c# - 我可以重定向到 [AcceptVerbs(HttpVerbs.Post)] ActionResult 吗?

转载 作者:太空宇宙 更新时间:2023-11-03 14:17:09 25 4
gpt4 key购买 nike

我正在尝试从另一个操作结果函数重定向到操作后结果。在这种情况下,我想从 Summary 函数重定向到 Index Post。那可能吗?

索引页是我的搜索页,Post 操作将返回结果。如果用户在地址栏中输入 ID,则可以执行搜索并显示结果。

public ActionResult Summary(string id)
{
//simple code
if(true)
{
return RedirectToAction("Index", "Home", HttpVerbs.Post);
}
return View();
}

最佳答案

参见 this previous answer在某些情况下,但我同意那里列出的第二个选项。在您的情况下,它可能不是第三方服务器,而是仅接受 POST 的 Index 操作。

Create the form to post to your server. When the form is submitted, show the user a page that has a form in it with all of the data you want to pass on, all in hidden inputs. Just show a message like "Redirecting...". Then, add a javascript event to the page that submits the form to the third-party server.

换句话说,Summary 将返回一个 View ,该 View 通过 JavaScript 发布到索引。

关于c# - 我可以重定向到 [AcceptVerbs(HttpVerbs.Post)] ActionResult 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6331472/

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