


Steps to enable external access for C# web application debugging
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
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:*" />
Example picture :
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:
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
Result:
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
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
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:
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
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Guide to Active Directory with C#. Here we discuss the introduction and how Active Directory works in C# along with the syntax and example.

Guide to C# Serialization. Here we discuss the introduction, steps of C# serialization object, working, and example respectively.

Guide to Random Number Generator in C#. Here we discuss how Random Number Generator work, concept of pseudo-random and secure numbers.

Guide to C# Data Grid View. Here we discuss the examples of how a data grid view can be loaded and exported from the SQL database or an excel file.

Guide to Factorial in C#. Here we discuss the introduction to factorial in c# along with different examples and code implementation.

Guide to Patterns in C#. Here we discuss the introduction and top 3 types of Patterns in C# along with its examples and code implementation.

Guide to Prime Numbers in C#. Here we discuss the introduction and examples of prime numbers in c# along with code implementation.

The difference between multithreading and asynchronous is that multithreading executes multiple threads at the same time, while asynchronously performs operations without blocking the current thread. Multithreading is used for compute-intensive tasks, while asynchronously is used for user interaction. The advantage of multi-threading is to improve computing performance, while the advantage of asynchronous is to not block UI threads. Choosing multithreading or asynchronous depends on the nature of the task: Computation-intensive tasks use multithreading, tasks that interact with external resources and need to keep UI responsiveness use asynchronous.
