Created
March 28, 2016 12:26
-
-
Save kleberksms/e4caec6202ddb7a2b24a to your computer and use it in GitHub Desktop.
example.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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