I'm trying to connect to a remote local server to get data from their Rest API. I'm on a ASP.NET MVC project and using RestSharp. When I establish VPN connection to the remote local server (via default Windows VPN connection), I'm be able to use Postman and successfully get data from their APIs. I will use this data to add new records to my DB or only display to users in my project.
But without VPN connection, I can't connect to the remote local server with Restsharp. It gives me timeout error. My C# codes for RestSharp configurations is like:
public async Task<ActionResult> PersonalList()
{
var options = new RestClientOptions("http://5.2.xxx.xx") //Remote local server IP
{
Proxy = new WebProxy("192.168.1.240", 12001), //Remote local API url and port
ThrowOnAnyError = true
};
var client = new RestClient(options);
client.Authenticator = new HttpBasicAuthenticator("myUserNameWhichIuseAtWindowsVPNConnection", "myPasswordWhichIuseAtWindowsVPNConnection");
var req = new RestRequest("/datasnap/rest/ServerMethods/GetPersonalList", Method.Get); //Get personal list API url
var resp = await client.ExecuteAsync(req);
return View();
}
I haven't changed or add any configuration to function or web.config for default credientals.
Now, I'm confused about "Am I trying the right way? Or is this type of connection to remote local server is impossible?". If this is wrong way, how should I deploy this project? If I deploy it to their local server, they only use it locally (In additon, I can't use their internet connection when I connect to their local server via VPN. I can use only their "192.168.1.240:12001".). I want them to use it when they are out of their company, not only locally.
Maybe I mixed a lot of different problems because of my confussion, sorry for that. But I will be very glad if you could suggest me what is the best practice for the solution of this situation.