C # enable external access for Web application debugging,

Source: Internet
Author: User
Tags line web

C # enable external access for Web application debugging,

There is a pain point when developing a Web application with C #, that is, when the machine starts Web application debugging with VS, external machines cannot access the Web application. This section describes how to allow LAN and Internet machines to access the Web applications of the local machine.

Directory

1. Set Intranet access

2. Set Internet access

 

1. Set Intranet access

Before setting, the local environment is as follows:

Operating System: Win7

IDE: Visual maxcompute 2010

Application: ASP.net

To access the web application from other machines on the LAN, perform the following four steps:

 

Step 1: Set the startup mode to IIS Express

Visual Studio uses its own Visual Studio development server by default when running Web applications. So we need to change the project to useIIS WebServer.

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

Procedure: Right-click Web project → properties → Web tab → select use local IIS Web Server → set port and Click create virtual directory

 

Step 2: Set the IIS Express applicationhost. config file

After you click the create virtual directory button in the above operationApplicationhost. configFile to create virtual directory information.

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

Find the configuration information of the above application and add<Binding>:

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

Example:

Note:: If IIS Express is enabled before modification, you must restart IIS Express to make the modification take effect.

 

Step 3: Set windows Firewall

After completing the preceding two steps, you also need to set a firewall to allow the port to pass through.

1) graphic operations:

Enable Windows Firewall advanced settings:

① Control Panel → Windows Firewall → Advanced Settings

② Create an inbound rule: TCP protocol and port 8081.

Example:

 

2) Command Line

You can also run 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

Result:

 

Step 4: Configure URL reservation items

In Windows 7, you can use Netsh.exe to configure HTTP settings.

Run the cmd command as an administrator:

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

This command adds a reserved URL for the specified URL namespace of all accounts.

For more information about netsh, visit MSDN: Configure HTTP and HTTPS.

 

Running Diagram

 

2. Set Internet access

After you have configured Intranet access, you can use either of the following methods to access the local machine:

1) Port ing

2) Intranet penetration

 

Port ing 2.1

Prerequisites: Has vro setting permissions.

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

 

2.2 Intranet penetration

When developing web applications in the company, not everyone can apply for port ing permissions. Therefore, an Intranet penetration solution is required.

There are many applications that provide Intranet penetration on the network. Here we usePeanut shells(Official Website: http://hsk.oray.com /).

Example:

Note:: The port number is added when OAuth2.0 performs domain name jump. The domain name port is 80, the local port is 8081, and the address after the jump is Domain Name: 8081, an error is displayed. To solve this problem, you only need to set the port of the Local web application to 80.

 

Running Diagram

 

====================================== Series of articles ==============================================

This article: 1.5 C # enable external access for Web application debugging

C # Article navigation

 

Related Article

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.