Hi I need to consume via c# a REST server via PortForwarding
I would like to use SSH.net this way
Do you see something wrong with this code? Since I can't understand where it should be uncorrect.
Thanks
Stefano
I would like to use SSH.net this way
using (var client = new SshClient("server", "username", "password"))
{
client.ConnectionInfo.Timeout = new TimeSpan(0, 0, 20);
client.Connect();
var port = new ForwardedPortLocal("127.0.0.1",1001, serverAddress, serverPort);
client.AddForwardedPort(port);
port.Exception += delegate(object sender, ExceptionEventArgs e)
{
Console.WriteLine(e.Exception.ToString());
};
port.Start();
//---START
var url = new Uri("http://127.0.0.1:1001/SomeRestApi");
var request = HttpWebRequest.Create(url);
var response = await Task.Factory.FromAsync<WebResponse>(request.BeginGetResponse,
request.EndGetResponse,
null)
.ContinueWith(task => (HttpWebResponse)task.Result);
//---END
port.Stop();
client.Disconnect();
}
The REST part is the one between ----START and ----END but it doesn't work. It gives the infamous Silverlight 'NotFoundException'.Do you see something wrong with this code? Since I can't understand where it should be uncorrect.
Thanks
Stefano