简体   繁体   English

Visual Studio 2017 - 在 IIS Express 中授予远程用户访问网站的权限

[英]Visual Studio 2017 - Giving remote users access to website in IIS Express

Been looking through and trying all guides i found on this topic but no luck.一直在浏览并尝试我在这个主题上找到的所有指南,但没有运气。 I am running and MVC project with HTTPS and want to access the debug site with some remote mobile devices to test out the website.我正在使用 HTTPS 运行 MVC 项目,并希望使用一些远程移动设备访问调试站点以测试该网站。 I followed a guide that almost work and i think I am pretty close to getting it to work.我遵循了一个几乎有效的指南,我认为我已经很接近让它发挥作用了。 Here are the steps I have done:以下是我所做的步骤:

  • Turn off Firewall关闭防火墙
  • Open projectfolder of website go to \\vs\\config\\ and open applicationhost.config打开网站的项目文件夹去\\vs\\config\\并打开applicationhost.config
  • Find your site and line that contains your mapped port like this:找到包含映射端口的站点和行,如下所示:

-edit it to get this result: - 编辑它以获得这个结果:

  • Tried to run Visual Studio as Admin at this point, Got regular error 400: Bad Request - Invalid Hostname when trying to access site from other computer此时尝试以管理员身份运行 Visual Studio,出现常规错误 400:错误请求 - 尝试从其他计算机访问站点时主机名无效
  • Opened CMD as Admin and ran the following command:以管理员身份打开 CMD 并运行以下命令:

netsh http add urlacl url=http://*:44363/ user=everyone - URL reservation successfully added netsh http add urlacl url=http://*:44363/ user=everyone - URL预留成功添加

-Tried to start Visual studio as admin and non admin. - 尝试以管理员和非管理员身份启动 Visual Studio。 Gets the following error message得到以下错误信息

"Unable to launch the IIS Express Web Server. Failed to reister URL " https://localhost:44363 " for site "x" Application. Error description: Cannot create file when that file already exists" “无法启动 IIS Express Web 服务器。无法为站点“x”应用程序重新注册 URL“ https://localhost:44363 ”。错误描述:该文件已存在时无法创建文件

-I then have to run cmd again and remove the url with the command: netsh http delete urlacl url=http://*:44363/ - 然后我必须再次运行 cmd 并使用以下命令删除 url:netsh http delete urlacl url=http://*:44363/

How do i get this to work with Visual Studio 2017 ?我如何让它与 Visual Studio 2017 一起使用? I cant be many steps from getting it to work.我不能让它开始工作很多步骤。 I have read many guides but none of them works我已经阅读了很多指南,但没有一个有效

Amazing how such a simple common need can be so painful to fulfill out of the box in 2017!令人惊讶的是,如此简单的共同需求在 2017 年开箱即用会如此痛苦!

Anyway https://github.com/icflorescu/iisexpress-proxy worked nicely for me.无论如何https://github.com/icflorescu/iisexpress-proxy对我来说效果很好。

Install it with node:使用节点安装它:

npm install -g iisexpress-proxy

Then its just something like:然后它就像:

iisexpress-proxy 51123 to 3000

Under 2 mins to get running.不到 2 分钟即可开始跑步。

Let me share my experience with Visual Studio and IIS Express that should help you.让我分享一下我使用 Visual Studio 和 IIS Express 的经验,应该会对您有所帮助。 I am not using HTTPS and my project type is Web site with WCF but you should be able to accomplish your goal.我没有使用 HTTPS,我的项目类型是带有 WCF 的网站,但您应该能够实现您的目标。 Here are prerequisites:以下是先决条件:

  1. IIS Express installed已安装 IIS Express
  2. Visual Studio installed已安装 Visual Studio
  3. Added url reservation for public port (netsh http add url=http://*:50001/ User=Everyone) from elevated command prompt.从提升的命令提示符添加了公共端口的 url 保留 (netsh http add url=http://*:50001/ User=Everyone)。
  4. Added firewall inbound rule for 50001 TCP port (Control Panel-->Windows Firewall-->Advances Settings-->Inbound Rules-->New Rule...)为 50001 TCP 端口添加防火墙入站规则(控制面板-->Windows 防火墙-->高级设置-->入站规则-->新规则...)

Now let us setup a project in VS.现在让我们在 VS 中设置一个项目。 I am using one of predefined templates with C#.我在 C# 中使用预定义模板之一。 Compile it and try to run it from VS.编译它并尝试从 VS 运行它。 At that moment VS is starting developer instance of IISExpress that helps your site to run.那时 VS 正在启动 IISExpress 的开发人员实例,以帮助您的站点运行。 You should be able to see IIS Express icon in Notification area.您应该能够在通知区域中看到 IIS Express 图标。 With right click you will see that your site is running and a port (we will call it VSPORT) that is assigned by VS.右键单击您将看到您的站点正在运行以及一个由 VS 分配的端口(我们称之为 VSPORT)。 This port must be different than reserved port (50001).此端口必须不同于保留端口 (50001)。 If you managed to accomplish this without problems then you have almost everything ready for running your site without VS.如果您成功地做到了这一点,那么您几乎已经准备好在没有 VS 的情况下运行您的网站。

  1. Go to your project folder转到您的项目文件夹
  2. Go to .vs folder转到 .vs 文件夹
  3. Go to config folder进入配置文件夹
  4. Open applicationhost.config打开 applicationhost.config
  5. Locate sites/your_site section找到网站/your_site 部分
  6. Copy everything between your_site and /your_site复制 your_site 和 /your_site 之间的所有内容

Now we need to add this info in "global" IIS Express config.现在我们需要在“全局”IIS Express 配置中添加此信息。

  1. Go to IIS Express folder (something like c:\\Users\\USERNAME\\Documents\\IISExpress)转到 IIS Express 文件夹(类似于 c:\\Users\\USERNAME\\Documents\\IISExpress)
  2. Go to config folder进入配置文件夹
  3. Open applicationhost.config打开 applicationhost.config
  4. Locate sites section.定位站点部分。
  5. Paste information about your site.粘贴有关您网站的信息。
  6. Change binding from更改绑定

binding protocol="http" bindingInformation="*:VSPORT:localhost"绑定协议="http" bindingInformation="*:VSPORT:localhost"

to

binding protocol="http" bindingInformation=" :50001: "绑定协议="http" bindingInformation=" :50001: "

  1. Save changes保存更改

With this change you may start IISExpress.exe directly and you can continue to use VS to work on you project at the same time.通过此更改,您可以直接启动 IISExpress.exe,同时您可以继续使用 VS 处理您的项目。

If you want to access it from other computers do it as http://YOURIP:50001/ .如果您想从其他计算机访问它,请使用http://YOURIP:50001/ Do have in mind that you need to ensure that your javascript code is NOT using address and port number directly.请记住,您需要确保您的 javascript 代码没有直接使用地址和端口号。

You can solve the problem by downloading the 'conveyor' library from extensions and update in Visual Studio.您可以通过从扩展中下载“传送带”库并在 Visual Studio 中更新来解决该问题。

You can access it from other devices.您可以从其他设备访问它。

  • Open Visual Studio打开 Visual Studio

  • Tools > Extensions and Updates工具 > 扩展和更新

  • Online > Visual Studio Marketplace在线 > Visual Studio 市场

  • Search 'Conveyor'搜索“传送带”
  • Download and install this extension下载并安装此扩展

When you launch the API, you can access it from other devices.当您启动 API 时,您可以从其他设备访问它。 This plugin creates a link from your own ip address.这个插件从你自己的 IP 地址创建一个链接。

Example: https://youripadress:5000/api/values示例: https://youripadress:5000/api/values

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

相关问题 Visual Studio 2015 IIS Express - Visual studio 2015 IIS Express IIS 不运行 Visual Studio 2017 中的项目 - IIS does not run the project in Visual Studio 2017 在Visual Studio中进行调试时,在浏览器中使用本地IIS服务器而不是IIS EXPRESS会收到“访问被拒绝”消息 - When debugging in Visual Studio I get message 'Access is denied' in the browser with Local IIS Server NOT with IIS EXPRESS IIS Express 未在 Visual Studio 2019 中运行 - IIS Express not running in Visual Studio 2019 IIS Express 不会在 Visual Studio 2019 中重新启动 - IIS Express does not restart in Visual Studio 2019 在使用IIS Express 8.0的Visual Studio 2013中进行调试时,无法访问使用Windows身份验证的[授权] MVC方法 - Can't access [Authorized] MVC method using Windows Authentication when debugging in Visual Studio 2013 using IIS Express 8.0 Visual Studio 2015和IIS Express会获得ERR_CONNECTION_REFUSED - Visual Studio 2015 and IIS Express get ERR_CONNECTION_REFUSED 使用IIS Express和Visual Studio 2012在开发中提供静态文件 - Serving static files in development with IIS Express and Visual Studio 2012 无法启动IIS表达错误Visual Studio 2015 - Unable to launch IIS express error Visual Studio 2015 Visual Studio 2010 IIS Express获取已配置的端口号 - Visual Studio 2010 IIS Express Get Configured Port Numbers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM