C # Web application debugging Open external access

Source: Internet
Author: User
Tags visual studio 2010

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 local and extranet machines to access native computers.

Directory

1. Set up intranet access

2. Setting up extranet access

1. Set up intranet access

Before setting up, the native environment is as follows:

operating system : Win7

IDE: Visual Studio 2010

application : ASP.

The following 4 steps are needed to enable other machines in the LAN to access the native Web app:

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

650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/153475/201612/153475-20161223173625182-134369426. PNG "style=" border:0px; "/>

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>:

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

Example Diagram :

650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/153475/201612/153475-20161227100154242-1177502518. PNG "style=" border:0px; "/>

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.

1) Graphics Operation:

Turn on advanced settings for Windows Firewall:

① Control Panel →windows firewall → advanced settings

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

Example Diagram :

650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/153475/201612/153475-20161227104109586-1228725774. PNG "style=" border:0px; "/>

2) command line

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

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

Results :

650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/153475/201612/153475-20161227104940351-1792163265. PNG "style=" border:0px; "/>

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:

1 netsh http Add urlacl url=http: //*:8081/user=everyone

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

For more information about Netsh, you can access related MSDN: Configure HTTP and HTTPS

Run diagram

650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/153475/201612/153475-20161227112423789-759415970. PNG "style=" border:0px; "/>

2. Setting up extranet access

Set up the intranet can be accessed, want to network of small partners to access this machine, can be through the following 2 ways:

1) port mapping

2) Intranet penetration

2.1 Port Mapping

Prerequisites : Have the router set permissions.

Set up a port mapping rule in the external router and jump to the LAN machine when accessing the external IP address. The concrete operation is not elaborated here.

2.2 Intranet Penetration

When developing Web applications in the company, not everyone can request port mapping permissions, so this time there will be an intranet penetration solution.

There are many applications available on the network to penetrate the intranet, the peanut shell is used here (official website: http://hsk.oray.com/).

Example :

650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/153475/201701/153475-20170103114930378-1823236444. PNG "style=" border:0px; "/>

Note : The OAuth2.0 will add the port number when the domain name jumps, this time the domain port is 80, the native port is 8081, the address after the jump is the domain name: 8081 will display the error. Workaround you only need to set the port of the native web app to 80.

Run diagram

650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/153475/201701/153475-20170103114940706-371957593. PNG "style=" border:0px; "/>


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.