-1
    [HttpPost]
    public ActionResult Welcome(FormCollection frm)
    {         

        frm["parameter1"] = "Welcome1";
        frm["parameter2"] = "Welcome2";
        frm["parameter3"] = "Welcome3";
        frm["parameter4"] = "Welcome4";
        return Redirect("https://www.example.com");
    }

Question :

I want to pass FormCollection Object when redirect to separate domain like "https://www.example.com"

Is this possible or not ?

Thanks in advance

adiga
  • 34,372
  • 9
  • 61
  • 83
User
  • 1,334
  • 5
  • 29
  • 61
  • if you are sending all your formcollection values to another domain why not directly submit from html instead of first sending form values to your server then sending to another domain. – Bhuban Shrestha Jun 08 '17 at 04:55
  • 2
    If you want to target another domain/server with specific URL, use `HttpWebRequest` with `WebRequest.Create` & specify `ContentType`, `Method` & `ContentLength`. – Tetsuya Yamamoto Jun 08 '17 at 04:58
  • @ Bhuban Shrestha I am doing same thing but I want to know is it possible because i want to hide some fields which I donot want print on html page – User Jun 08 '17 at 04:59
  • @ Tetsuya Yamamoto Please give small demo code which help to write code – User Jun 08 '17 at 05:01
  • You could pass those as parameters using query string. Just build the url properly like `https://www.example.com/?param1=Welcome1&param2=Welcome2` – jegtugado Jun 08 '17 at 07:10

2 Answers2

0

You can pass the id as part of the routeValues parameter of the RedirectToAction() method.

return RedirectToAction("Action", new { id = 20 });

Reshma
  • 436
  • 3
  • 13
0

Redirecting is HTTPGET request type, but you want to send data with your request, so it isn't redirecting process, you can use HttpClient class for posting data, refer to this question.

vahid kargar
  • 800
  • 1
  • 9
  • 23