Steps to enable external access for C# web application debugging

Y2J
Release: 2017-04-17 16:45:12
Original
1779 people have browsed it

There is a pain point when developing web applications using C#, which is that external machines cannot access the web application when using VS to enable web application debugging on this machine. Here we will introduce how to allow LAN and external network machines to access local web applications through settings.

Directory

1. Set up intranet access

2. Set up external network access

1. Set up intranet access

Before setting up, the local environment is as follows:

Operating system: win7

IDE: Visual Studio 2010

Application: asp.net

Wanting other machines in the LAN to access the local web application involves the following four steps:

Step 1: Set the startup mode to IIS Express

When Visual Studio runs the web application, it is used by default Own Visual Studio development server. So first we need to change the project to use IIS web server.

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

Steps: Right click Web project → Properties → Web tab → Check Use local IIS Web server → Set the port and click the [Create virtual directory] button

Steps to enable external access for C# web application debugging

Step 2: Set up IIS Express applicationhost.config file

After clicking the [Create Virtual Directory] button in the above operation, the virtual directory information will be created in the applicationhost.config file of IIS Express.

Default file path: %userprofile%\My Documents\IISExpress\config\applicationhost.config

Find the configuration information of the above application and add one:

<binding protocol="http" bindingInformation="*:8081:*" />
Copy after login

Example picture :

Steps to enable external access for C# web application debugging

Note: If IIS Express has been started before the modification, IIS Express needs to be restarted after the modification to take effect.

Step 3: Set up windows firewall

After completing the above 2 steps, you also need to set up the firewall to allow this port to pass.

1) Graphical operation:

Open the advanced settings of Windows Firewall:

① Control Panel → Windows Firewall → Advanced Settings

② Create an inbound Rules: Protocol TCP, port is 8081.

Example picture:

Steps to enable external access for C# web application debugging

2) Command line

You can also execute the following command to add an inbound rule:

netsh advfirew all firewall Add rule name=\"命令行Web访问8081\" dir =in protocol=tcp localport=8081 action =allow
Copy after login

Result:

Steps to enable external access for C# web application debugging

Step 4: Configure URL reservations

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

Run cmd command as administrator:

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

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

More For netsh information, you can visit the relevant MSDN: Configuring HTTP and HTTPS

Run diagram

Steps to enable external access for C# web application debugging

2. Set up external network access

Set up internal After the network is accessible, friends who want to access the machine from the external network can use the following two methods:

1) Port mapping

2) Intranet penetration

2.1 Port mapping

Prerequisite: Have router setting permission.

Set a port mapping rule in the external router to jump to the LAN machine when accessing the external IP address. The specific operations are not explained here.

2.2 Intranet penetration

When developing web applications within the company, not everyone can apply for port mapping permissions, so at this time there is a solution for intranet penetration .

There are many applications on the Internet that provide intranet penetration. The one used here is peanut shell (official website: hsk.oray.com/).

Example:

Steps to enable external access for C# web application debugging

Note: When WeChat OAuth2.0 performs domain name jump, the port number will be added. At this time, the domain name port is 80 and the local port is 8081, and the address after the jump is domain name: 8081, an error will be displayed. The solution is to set the port of the native web application to 80.

Run Chart

Steps to enable external access for C# web application debugging

The above is the detailed content of Steps to enable external access for C# web application debugging. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!