【问题标题】:Redirect with query string in Asp.Net Core 2.x在 Asp.Net Core 2.x 中使用查询字符串重定向
【发布时间】:2019-11-01 06:08:16
【问题描述】:

我正在使用查询字符串调用操作名称 PaymentStatus,并将查询字符串参数与我的模型绑定。

在这里。

[HttpGet("PaymentStatus")]
    public ActionResult PaymentStatus([FromQuery]ResponseMsgVM res)
    {
        return Redirect(@"http://localhost:27089");
    }

现在的问题是我想用当前请求的查询字符串重定向到另一个 URL。

请帮帮我,我该怎么做?

【问题讨论】:

    标签: c# asp.net-core asp.net-core-2.1 http-redirect


    【解决方案1】:

    从请求中提取当前查询字符串并包含在重定向 URL 中

    [HttpGet("PaymentStatus")]
    public ActionResult PaymentStatus([FromQuery]ResponseMsgVM res) {
        var queryString = Request.QueryString;
        //use querystring to build redirect URL
    
        return Redirect(@"http://localhost:27089" + queryString);
    }
    

    【讨论】:

      猜你喜欢
      • 2022-03-30
      • 2012-09-09
      • 2014-11-03
      • 2012-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多