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

标签 c# .net asp.net asp.net-mvc visual-studio-2010

我正在尝试从另一个操作结果函数重定向到操作后结果。在这种情况下,我想从 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/

相关文章:

c# - 具有多种日期时间表示形式的 CultureInfo

c# - 使用 Linq 更新集合中除一个对象之外的所有对象

c# - WPF Canvas 性能 - 多次调用 children.add

c# - 通过 SMTP 客户端发送电子邮件时出错

c# - Visual Studio Ultimate 运行速度很慢 :(

c# - 如何获取客户端的本地 IP 地址,例如 192.168.0.1?

c# - 静态变量是线程安全的吗? C#

c# - 应用程序见解和标签

c# - 401 未经授权的异常与 SSL 的 WebRequest

c# - 数据库 'Database Name' 的凭据无效。 MongoDB 2.6.2