There is a pain point when developing web applications with c#,That is, when the web application debugging is started on the local machine, the external machine cannot access the web application. Here will introduce how to allow local and external network machines to access the web application through the settings.
table of ContentsSet up intranet access Set up extranet access
1. Set up intranet access
Before setting,The local environment is as follows:
ide:visual studio 2010
Wanting to enable other machines in the local area network to access the native web application includes the following 4 steps:
Step 1:Set the startup method to iis express
visual studio runs its web application by default using its own visual studio development server.So first change the project to use iis web server.
step:Right-click the web project → Properties → web tab → check Use local iis web server → set the port and click the [create virtual directory] button
Step 2:Set applicationhost.config file for iis express
After clicking the [Create Virtual Directory] button above, it will be displayed inof iis expressapplicationhost.configfile creates virtual directory information.
File default path:%userprofile%\ my documents \ iisexpress \ config \ applicationhost.config
Find the configuration information for the application above,Add a<binding>:
<binding protocol="http" bindinginformation="*:8081:*" />
note:If iis express has been started before modification, you need to restart iis express after modification to take effect.
Step 3:Set up a windows firewall
After completing the above 2 steps, you also need to set up a firewall to allow this port to pass.
1) Graphic operation:
Open advanced settings for windows firewall:
① Control Panel → Windows Firewall → Advanced Settings
② Create an inbound rule:protocol tcp, port 8081.
2) Command line
You can also execute the following command to add an inbound rule:
netsh advfirewall firewall add rule name=\ "command line web access 8081 \" dir=in protocol=tcp localport=8081 action=allow
Step 4:Configure URL retention
In Windows 7, you can use the netsh.exe tool to configure the http settings, allowing specified URLs to pass.
Run cmd command as administrator:
netsh http add urlacl url=http://*:8081/user=everyone
This command adds a url reservation to the specified url namespace for all accounts
More netsh information, you can visit related msdn:Configure http and https
2. Set up Internet access
After setting up the intranet to be accessible,Want friends from outside the network to access this machine,There are two methods:
1) Port mapping
2) Intranet penetration
2.1 Port mapping
Prerequisite:Have router setting permissions.
Set a port mapping rule in the external router.Go to the LAN machine when accessing the external IP address.The specific operation is not explained here.
2.2 Intranet penetration
When developing web applications in a company, not everyone can apply for port mapping permissions,So at this time there must be a solution for intranet penetration.
There are many applications that provide intranet penetration on the network.Here is usedPeanut shells(Official website :).
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- python 3x - typeerror: 'method' object is not subscriptable
- i want to call a child component method from a parent in vuejs
- xcode - pod install [!] no `podfile 'found in the project directory
- dart - flutter: the instance member'stars' can't be accessed in an initializer error