logo

Thông báo

Icon
Error

Chia sẻ
Tùy chọn
Xem
Xem bài viết cuối
Offline admin  
#1 Đã gửi : 14/10/2018 lúc 02:42:03(UTC)
admin

Danh hiệu: Administration

Chức danh:

Nhóm: Administrators
Gia nhập: 23-07-2013(UTC)
Bài viết: 5,964
Man
Viet Nam
Đến từ: Vietnam

Cảm ơn: 9 lần
Được cảm ơn: 2 lần trong 2 bài viết

Accessing an IIS Express site from a remote computer

ometimes (waaaay to often) I have to check that a site I’m working on looks like it should in Internet Explorer 6, Safari on Mac or some other browser that I can’t run in Windows 7. In this case I wanted to access it from IE6 running in XP Mode.  I could of course deploy it to IIS and make it publicly available, but since I’m now using IIS Express for running my sites from Visual Studio instead of the built-in web server Cassini, it almost simple to let other computers on my network access the site.

This post by Scott Hanselman almost describes how to do it, but since I had to make some adjustments I thought I might write a shorter post with just the steps you need for this.

1 – Bind your application to your public IP address

Normally when you run an application in IIS Express, it’s only accessible on http://localhost:[someport]. In order to access it from another machine, it needs to be bound to your public IP address as well. Open D:\Users[YourName]\Documents\IISExpress\config\applicationhost.config and find your site.

UPDATE FOR VISUAL STUDIO 2015: As was pointed out to me in a comment by Søren Nielsen, in Visual Studio 2015 the IIS Express configuration files have moved. They are now separate per project, and stored in /{project folder}/.vs/config/applicationhost.config. Which is much better, in my opinion, just don't forget to add .vs/ to your .gitignore/.hgignore files!

You will find something like this:

Mã:
<site name="Alpha.Web" id="2" >

<application path="/" >

<virtualDirectory path="/" physicalPath="C:\Users\Johan\HgReps\Alpha\Alpha.Web" />

</application>

<bindings>

        <binding protocol="http" bindingInformation="*:58938:localhost"/>

</bindings>

</site>

<binding protocol="http" bindingInformation="*:58938:192.168.1.42" />

In <bindings>, add another row:

 (But with your IP, and port number, of course)

2 - Allow incoming connections

If you’re running Windows 7, pretty much all incoming connections are locked down, so you need to specifically allow incoming connections to your application. First, start an administrative command prompt. Second, run these commands, replacing 192.168.1.42:58938 with whatever IP and port you are using:

Mã:
C:\Windows\system32>netsh http add urlacl url=http://192.168.1.42:58938/ user=everyone

This just tells http.sys that it’s ok to talk to this url.

Mã:
C:\Windows\system32>netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=58938 profile=private remoteip=localsubnet action=allow

This adds a rule in the Windows Firewall, allowing incoming connections to port 58938 for computers on your local subnet.

To delete the rules you can do this:

Mã:
netsh http show urlacl
netsh http delete urlacl url=http://192.168.1.42:58938/

And there you go, you can now press Ctrl-F5 in Visual Studio, and browse you site from another computer!

Notes:

In order to mess up with mess up with your “applicationhost.config”, you can use the IIS Express Proxy by running the command in command prompt:

Mã:
iisexpress-proxy 58938 to 3000

…and then you can point your remote devices to http://192.168.1.42:3000.

Proxy port can be anything you like between 1025 and 65535.

If you use local IIS, you have to  restart IIS in between making the changes and trying to test them

Source : https://johan.driessen.se/posts/Accessing-an-IIS-Express-site-from-a-remote-computer

Ai đang xem chủ đề này?
OceanSpiders 2.0
Di chuyển  
Bạn không thể tạo chủ đề mới trong diễn đàn này.
Bạn không thể trả lời chủ đề trong diễn đàn này.
Bạn không thể xóa bài của bạn trong diễn đàn này.
Bạn không thể sửa bài của bạn trong diễn đàn này.
Bạn không thể tạo bình chọn trong diễn đàn này.
Bạn không thể bỏ phiếu bình chọn trong diễn đàn này.

| Powered by YAF.NET 2.2.4.14 | YAF.NET © 2003-2019, Yet Another Forum.NET
Thời gian xử lý trang này hết 0.224 giây.