简体   繁体   English

Visual Studio 在本地机器上运行,服务器的 IP

[英]Visual Studio runs on local machine with server's IP

I need a small direction for below task.我需要一个小方向来完成以下任务。

We are consuming APIs for getting some values.我们正在使用 API 来获取一些值。 The company who written APIs, allows only our server IP for making request.编写 API 的公司只允许我们的服务器 IP 发出请求。 (Basically, I cannot make API calls with my local machine.) I did the develop on visual studio and now need to test that the code is working fine or not. (基本上,我无法使用本地机器进行 API 调用。)我在 Visual Studio 上进行了开发,现在需要测试代码是否正常工作。 If I deploy the project on the server seems to be ok.如果我在服务器上部署项目似乎没问题。 But if there is an error in the code, then I need to do the changes and deploy it again and again.但是如果代码中有错误,那么我需要进行更改并一次又一次地部署它。 That is bit horrible.这有点可怕。 Also I won't be able to debug.我也无法调试。

What my question is, how to run Visual studio in my local machine and particular API call goes with server?我的问题是,如何在我的本地机器上运行 Visual Studio,并且特定的 API 调用与服务器一起使用? What is the easiest way to do this?最简单的方法是什么? Any expert can show me at least a direction, since I never done a task like before.任何专家都可以至少给我一个方向,因为我从来没有像以前那样完成过任务。

Additional Info.附加信息。

  • The Server runs on cent os and have a static IP.服务器在 cent os 上运行,并具有 static IP。 (I have the relevant credentials for accessing to the service with SSH) (我有使用 SSH 访问服务的相关凭据)
  • My local machine is Widows based and has a dynamic IP我的本地机器是基于寡妇的,并且有一个动态的 IP
  • Develop with Visual studio 2019 with C#使用 C# 使用 Visual Studio 2019 进行开发

I can suggest several directions我可以建议几个方向

  • proxy.代理人。 Just configure http or socks proxy on your server then use such a proxy on your machine.只需在您的服务器上配置 http 或 socks 代理,然后在您的机器上使用这样的代理。 All requests will go through your server and the API will see the server's IP.所有请求将通过您的服务器 go 和 API 将看到服务器的 IP。 If the API is a pure-http, this should be enough.如果 API 是纯 http,这应该足够了。
  • tunnel/VPN.隧道/VPN。 Configure VPN server on your server, configure your dev machine as the client and route traffic inside VPN tunnel.在您的服务器上配置 VPN 服务器,将您的开发机器配置为客户端并在 VPN 隧道内路由流量。 In this case all traffic, not only http, will go through your server and even if API using some non-http things, it should still work在这种情况下,所有流量,不仅 http,go 将通过您的服务器,即使 API 使用一些非 http 的东西,它应该仍然有效
  • remote debugging.远程调试。 Visual studio supports remote debugging. Visual Studio 支持远程调试。 So, you can configure it on your server, then you will be able to run the code on server and debug it from dev machine in real time.所以,你可以在你的服务器上配置它,然后你就可以在服务器上运行代码并从开发机器上实时调试它。 I believe that for web-apps there is also a remote deploy, when the app is deployed to the specific server automatically after the every build.我相信对于 web-apps 还有一个远程部署,当应用程序在每次构建后自动部署到特定服务器时。 So, when proper configured, this will allow you to work on remote server nearly as on local one.因此,如果配置正确,这将允许您在远程服务器上工作,就像在本地服务器上一样。

To remote-debug a .NET application on a linux/unix server, do the following:要在 linux/unix 服务器上远程调试 .NET 应用程序,请执行以下操作:

Start your process (ie dotnet myApp.dll) on the remote server.在远程服务器上启动您的进程(即 dotnet myApp.dll)。

Then, in Visual Studio, use Debug->Attach to process.然后,在 Visual Studio 中,使用 Debug->Attach to process。 Select SSH as transport, and enter "username@IP" in the address box (ie "me@192.168.1.43"). Select SSH 作为传输,在地址框中输入“用户名@IP”(即“me@192.168.1.43”)。 Now a dialog opens where you can specify some connection details.现在将打开一个对话框,您可以在其中指定一些连接详细信息。 When everything works, you will be presented with the process list on your server.当一切正常时,您将看到服务器上的进程列表。 (Note: This works only if your process does not run as root, otherwise you have to use "root@IP" and previously set a SSH password for root). (注意:这仅在您的进程不以 root 身份运行时才有效,否则您必须使用“root@IP”并且之前为 root 设置了 SSH 密码)。

As @Serg notes, there might be an automatic deploy mechanism available, but otherwise you can use a tool such as WinSCP to automatically synchronize your build output with the server.正如@Serg 所指出的,可能有一个自动部署机制可用,但是您可以使用诸如 WinSCP 之类的工具来自动将您的构建 output 与服务器同步。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio开发服务器使用机器ip自动重定向到默认端口 - visual studio development server automatically redirects to default port with machine ip 是否可以将Visual Studio 2017设置为在远程Linux机器而不是本地机器上运行和调试.NET Core C#应用程序? - Is it possible to setup Visual Studio 2017 such that it runs and debugs a .NET Core C# application on remote Linux machine instead of local machine? 使用自定义URL在Visual Studio上进行调试(但在本地计算机上) - Debug on Visual Studio with custom url (but in local machine) 视频无法使用Unity在Visual Studio中的本地计算机上播放 - Video is not playing on local Machine in visual studio using unity 本地计算机上的静态文件未从Visual Studio发布到IIS - Static files on local machine not being published to IIS from visual studio 使用 Visual Studio 在我的本地计算机上设置测试环境 - Setup a test environment on my local machine using Visual Studio 调试时Visual Studio 2017尝试使用IP连接到本地Mysql - Visual Studio 2017 tries to connect to Local Mysql with an IP when debugging 获取服务器计算机IP - Get Server Machine IP Linq查询在本地计算机上运行良好,但在服务器上收到“连接已重置”错误 - Linq query runs fine on local machine, but get “The connection was reset” error on the server C# - 查找我机器的本地 IP 地址而不是 VM - C# - Finding my machine's local IP Address and not the VM's
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM