Skip to content

Instantly share code, notes, and snippets.

@kleberksms
Created March 28, 2016 12:26
Show Gist options
  • Save kleberksms/e4caec6202ddb7a2b24a to your computer and use it in GitHub Desktop.
Save kleberksms/e4caec6202ddb7a2b24a to your computer and use it in GitHub Desktop.
example.cs
public IHttpActionResult GetWithControllerRedirect(string system, string rcontroller)
{
try
{
string url = $"http://localhost:55164/api/{rcontroller}";
var request = (HttpWebRequest)WebRequest.Create(string.Format(url));
request.Method = "GET";
request.ContentType = "application/json; charset=utf-8";
request.Accept = "application/json; charset=utf-8";
var response = (HttpWebResponse)request.GetResponse();
var stream = new StreamReader(response.GetResponseStream());
return Ok(JsonConvert.DeserializeObject<dynamic>(stream.ReadToEnd()));
}
catch (Exception ex)
{
Errors.WriteErrorFile(ex, @"C:\exception_errors.txt");
return InternalServerError();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment