We have a private server that I cannot access.
We have another public server that I can access.
The public server can access the private server. (ie. A proxy server)
So I want to build an ASP.Net framework app on the public server that will simply forward all query parameters, body, headers, everything, to the private server.
When I make a route, how can I just forward everything to the private server's URL?
I have this so far but not sure if I'm thinking about this the right way. I feel like there's a way that is more automated:
[System.Web.Mvc.Route("search")]
public object Search()
{
var request = HttpContext.Current.Request;
var BaseUrl = "http://my-private-server-url";
var client = new RestClient(BaseUrl);
var newRequest = new RestRequest(request.HttpMethod);
// The code below errors:
// Cannot convert from
// 'System.Collections.Specialized.NameValueCollection' to
// 'System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, string>>'
newRequest.AddHeaders(request.Headers);
// How do I forward the request body too?
var response = client.Execute(newRequest);
return response.Content;
}