无法通过从浏览器中键入URL来直接访问我的Web api数据 [英] Unable to access my web api data directly by typing the url from a browser
问题描述
大家好!
我刚刚开始我的第一个api项目。它成功运行并在浏览器上以xml格式显示我的数据。浏览器上的url说localhost:< portno> / api / employees
我的问题是:如何从另一台机器上的浏览器直接键入上面的URL(localhost:< portno> / api / employees)来访问相同的数据?
我尝试了什么:
我刚开始使用我的第一个api项目。它成功运行并在浏览器上以xml格式显示我的数据。浏览器上的url说localhost:< portno> / api / employees
我的问题是:如何从另一台机器上的浏览器直接键入上面的URL(localhost:< portno> / api / employees)来访问相同的数据?
Hi Everyone!
I have just started with my first api project. It runs successfully and shows me my data in xml format on the browser.The url on the browser says localhost:<portno>/api/employees
My question is: how can i access the same data by directly typing on the above url (localhost:<portno>/api/employees) from a browser on another machine?
What I have tried:
I have just started with my first api project. It runs successfully and shows me my data in xml format on the browser.The url on the browser says localhost:<portno>/api/employees
My question is: how can i access the same data by directly typing on the above url (localhost:<portno>/api/employees) from a browser on another machine?
推荐答案
假设您在两台计算机之间没有防火墙,只需将localhost替换为您计算机的名称或IP地址。
因此,而不是:http:// localhost:port / api / employees
使用:http:// your-pc-name:port / api / employees
如果计算机之间有防火墙,则需要打开端口或托管API在端口80上的IIS中,而不是使用Visual Studio的内置Web服务器。
Assuming you don't have a firewall between the two computers, just replace "localhost" with the name or IP address of your computer.
So instead of:http://localhost:port/api/employees
Use:http://your-pc-name:port/api/employees
If you have a firewall between the computers, you'll either need to open the port, or host your API in IIS on port 80 instead of using Visual Studio's built-in web server.
这篇关于无法通过从浏览器中键入URL来直接访问我的Web api数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!