Redirect with query string in Asp.Net Core 2.x

Viewed 3989

I'm calling an action name PaymentStatus with a query string and I'm binding query string parameters with my model.

Here it is.

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

Now problem is that I want to Redirect to another URL with the query string of the current request.

Please help me how can I do this?

1 Answers

Extract current query string from request and include in redirect 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);
}
Related