Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 764
habib Avatar asked Jan 26 '23 04:01

habib


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);
}
like image 140
Nkosi Avatar answered Feb 03 '23 22:02

Nkosi