One disadvantages of using IIS Express is it not allow to be accessed from other computer by default. You can solve the problem by moving your project to local IIS (which I described here).
But if you still want to use IIS Express, this tutorial will guide you how to enable accessing IIS Express from remote computer.
1Open IIS Manager. Click on your server and click 'Authentication' on right pane
and set ASP.NET Impersonation to disabled
2Edit hosts file
C:\windows\System32\drivers\etc\hosts
and add your site name with your computer IP. Your site name will be used on later step.3Open
applicationhost.config
. The location is depend on version of Visual Studio as follows- Visual Studio 2013 and below:
C:\Users\<your_username>\Documents\IISExpress\config\applicationhost.config
- Visual Studio 2015 and above:
<path_to_your_project>\.vs\config\applicationhost.config
Then scroll down to
<site>
tag of your project. Look at the <bindings>
tag. You will see localhost binding in format like this<binding protocol="http" bindingInformation="*:<website_port>:localhost" />
now, copy this line and paste below it. Then, edit 'localhost' to name that you used in hosts file in step 2. The result will be like this
<binding protocol="http" bindingInformation="*:<website_port>:localhost" /> <binding protocol="http" bindingInformation="*:<website_port>:<name_you_used_in_hosts_file>" />
Check that everything is OK then save and close the file.
4Next step is to add permission to let other computer access your website. Open command line as administrator. Then type this command and hit enter.
netsh http add urlacl url=http://<name_in_host_file>:<website_port_in_step_3>/ user=everyone
and don't forget to give permission to firewall too. You can add rule by type this command and hit enter
netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=<website_port_in_step_3> profile=private remoteip=localsubnet action=allow
5Finally, run your IIS Express. If you use Visual Studio 2013 and below, use this command
"C:\Program Files (x86)\IIS Express\iisexpress" /site:<your_site_name_in_applicationhost.config>
For Visual Studio 2015 and above, use this command
"C:\Program Files (x86)\IIS Express\iisexpress" /config:<path_to_your_project>\.vs\config\applicationhost.config /site:<your_site_name_in_applicationhost.config>
Above code will run your website in 32 bit, If you want 64 bit, just change
IISExpress.exe
path to C:\Program Files\IIS Express\iisexpress
If everything goes well, command above will output like this
Successfully registered URL <your_url_you_set_in_step_3>
IIS Express is running.
Then you now can access your website from remote computer!
Happy Coding!
No comments:
Post a Comment