C # Web application debugging Open external access

Source: Internet
Author: User

This article is shared from Http://www.cnblogs.com/polk6/archive/2017/01/03/6215659.html, where only records are made.

A pain point when developing web Apps in C # is that the external machine cannot access this web app when it is debugged with vs. Web application debugging. This will show you how to set up a web app that allows LAN access to native computer.

First step: Set startup mode to IIS Express

When Visual Studio runs a web app, it uses its own Visual Studio development server by default. So first change the project to use the IIS Web server.

First make sure the machine is installed with IIS Express, (10.0 version): https://www.microsoft.com/zh-CN/download/details.aspx?id=48264

Step : Right-click Web Project → properties →web tab → Check Use local IIS Web server → set port and click on "Create virtual directory" button

Step Two: Set the IIS Express ApplicationHost.config file

When you click on the "Create virtual directory" button above, the virtual directory information is created in the IIS Express applicationhost.config file.

file Default path :%USERPROFILE%\My documents\iisexpress\config\applicationhost.config

Locate the configuration information for the application above and add a <binding>:

<binding protocol= "http" bindinginformation= "*:1851:*"/>

Example Diagram :

Note : If you have started IIS Express before you modify it, you will need to restart IIS Express for the changes to take effect.

Step three: Set up Windows Firewall

After completing the 2 steps above, you will also need to set up the firewall to allow this port to pass (if you shut down the firewall, this can be omitted).

1) Graphics Operation:

Turn on advanced settings for Windows Firewall:

① Control Panel →windows firewall → advanced settings

② creates an inbound rule: Protocol TCP, Port 1851.

Example Diagram :

2) command line

You can also add an inbound rule by executing the following command:

netsh advfirewall firewall Add rule name=\"命令行Web访问8081\" dir=inprotocol=tcp localport=8081 action=allow

Fourth step: Configure the URL reservation

In Windows 7, you can use the Netsh.exe tool to configure HTTP settings to allow the specified URL to pass.

Run the cmd command as Administrator:

netsh http add urlacl url=http://*:8081/ user=everyone

This command adds a URL reservation for the specified URL namespace for all accounts

Example Diagram :

With the above settings, you can ensure that you can access the network when debugging.

C # Web application debugging Open external access

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.